Discussion:
Preserving single comment characters in file extracted from .dtx
(too old to reply)
Peter Flynn
2020-05-08 21:06:20 UTC
Permalink
I have a .dtx file which contains (apart from the .sty file) a number of
short LaTeX documents which get extracted, eg

% \iffalse
%<*testfile>
% !TEX TS-program = xelatex
% !TEX encoding = UTF-8 Unicode
% !BIB TS-program = biber
%% Use this as a test file
\documentclass{foobar}
\begin{document}
Stuff
\end{document}
%</testfile>
% \fi

However, when extracted via the .ins file, the result starts with the
double-commented line "Use this as a test file", I think because
DocStrip is removing the single-comment lines.

Is there a way to make it preserve those single-comment lines?

Peter
Charles P. Schaum
2020-05-08 21:53:14 UTC
Permalink
Post by Peter Flynn
I have a .dtx file which contains (apart from the .sty file) a number of
short LaTeX documents which get extracted, eg
% \iffalse %<*testfile>
% !TEX TS-program = xelatex % !TEX encoding = UTF-8 Unicode % !BIB
TS-program = biber %% Use this as a test file \documentclass{foobar}
\begin{document}
Stuff \end{document}
%</testfile>
% \fi
However, when extracted via the .ins file, the result starts with the
double-commented line "Use this as a test file", I think because
DocStrip is removing the single-comment lines.
Is there a way to make it preserve those single-comment lines?
Peter
I just inserted a space before (left of) each single comment mark that
you wanted preserved and ran it through a skeleton ins file. It preserved
the comments as long as the leading space was there. This is how some
verbatim macros work with dtx files. They \@gobble the first space and
show the comment mark, then the verbatim line. Unless having leading
space is a deal-breaker, it should work. TeXworks picked up on the
compilation directives just fine and used xelatex to compile it after I
changed the class to article.

Charles
--
Convert dot for email replies
Peter Flynn
2020-05-08 22:36:33 UTC
Permalink
Post by Charles P. Schaum
Post by Peter Flynn
I have a .dtx file which contains (apart from the .sty file) a number of
short LaTeX documents which get extracted, eg
% \iffalse %<*testfile>
% !TEX TS-program = xelatex % !TEX encoding = UTF-8 Unicode % !BIB
TS-program = biber %% Use this as a test file \documentclass{foobar}
\begin{document}
Stuff \end{document}
%</testfile>
% \fi
However, when extracted via the .ins file, the result starts with the
double-commented line "Use this as a test file", I think because
DocStrip is removing the single-comment lines.
Is there a way to make it preserve those single-comment lines?
Peter
I just inserted a space before (left of) each single comment mark
that you wanted preserved and ran it through a skeleton ins file. It
preserved the comments as long as the leading space was there. This
first space and show the comment mark, then the verbatim line. Unless
having leading space is a deal-breaker, it should work. TeXworks
picked up on the compilation directives just fine and used xelatex to
compile it after I changed the class to article.
Thank you! I assumed the % had to be in col 1.

Peter
Nicola Talbot
2020-05-09 09:21:11 UTC
Permalink
Post by Peter Flynn
I have a .dtx file which contains (apart from the .sty file) a number of
short LaTeX documents which get extracted, eg
% \iffalse
%<*testfile>
% !TEX TS-program = xelatex
% !TEX encoding = UTF-8 Unicode
% !BIB TS-program = biber
%% Use this as a test file
\documentclass{foobar}
\begin{document}
Stuff
\end{document}
%</testfile>
% \fi
However, when extracted via the .ins file, the result starts with the
double-commented line "Use this as a test file", I think because
DocStrip is removing the single-comment lines.
Is there a way to make it preserve those single-comment lines?
You can use the "guard expression" where %<<END_TAG starts the block and
%END_TAG ends it. You can choose END_TAG but it needs to match exactly
(spaces count). For example:

%<<COMMENT
% !TEX TS-program = xelatex
% !TEX encoding = UTF-8 Unicode
% !BIB TS-program = biber
%% Use this as a test file
%COMMENT

Regards
Nicola Talbot
--
Home: http://www.dickimaw-books.com/
Creating a LaTeX Minimal Example:
http://www.dickimaw-books.com/latex/minexample/
Peter Flynn
2020-05-09 21:16:39 UTC
Permalink
[...]
Post by Nicola Talbot
Post by Peter Flynn
Is there a way to make it preserve those single-comment lines?
You can use the "guard expression" where %<<END_TAG starts the block and
%END_TAG ends it. You can choose END_TAG but it needs to match exactly
%<<COMMENT
% !TEX TS-program = xelatex
% !TEX encoding = UTF-8 Unicode
% !BIB TS-program = biber
%% Use this as a test file
%COMMENT
That's great, thank you so much. I somehow missed this syntax.

Peter

Loading...