## digitalmars.D.announce - PDF verssion of D manuals

• bls (6/6) Dec 11 2006 Hi,
• Jeff (4/14) Dec 11 2006 Rather than writing to PDF directly, we'd probably be better off
• Jeff (3/19) Dec 12 2006 Come to think of it, if nobody's already working on this, I'd be willing...
• BCS (6/9) Dec 12 2006 Feel free to start on it, the only reason I'll not doing it yet is that:
• Walter Bright (4/15) Dec 12 2006 I did put the doc sources up. They still have the odd use of html tags
• BCS (6/22) Dec 12 2006 I guess I could do a few conversions. I was kinda hoping to get a
• Walter Bright (3/15) Dec 13 2006 Just pick one or two of the files to develop the technique. Once that
• BCS (9/13) Dec 14 2006 Here is the first attack
• Walter Bright (3/4) Dec 14 2006 It's a good start. If you can write up the roadblocks you're
• BCS (53/60) Dec 14 2006 The problem for tables is that TeX defines tables sizes with a syntax
• Bill Baxter (21/42) Dec 14 2006 I'm pretty certain you could write a TeX macro to do that. Don't ask me...
• Frits van Bommel (5/23) Dec 14 2006 Ooh, using TeX instead of DDoc for this is something I hadn't
• Bill Baxter (10/36) Dec 14 2006 I spent a few minutes searching the web (yet again) for decent
• Christian Kamm (6/7) Dec 14 2006 This should do the trick:
• Frits van Bommel (16/41) Dec 14 2006 I've been messing around with this a bit. Attached you'll find an
• BCS (9/17) Dec 14 2006 Thanks.
• Frits van Bommel (13/22) Dec 14 2006 The loose word at the top with a trailing comma was just too ugly to let...
• Christian Kamm (5/8) Dec 14 2006 The tabularx package might do what you want:
• Frits van Bommel (14/23) Dec 15 2006 Unfortunately, it seems to default[1] to all 'X' columns having the same...
• Christian Kamm (6/10) Dec 15 2006 Probably, but I don't know how. It only seems to work as a column
• Christian Kamm (5/7) Dec 15 2006 I found it! (in the documentation of array.sty)
• BCS (5/5) Dec 15 2006 Thanks all for the help! I'm no TeX grue, I just use the stuff. I'll be ...
• Frits van Bommel (14/19) Dec 15 2006 I've updated my tabularx code to use tabulary, result is attached.
• BCS (7/7) Dec 15 2006 version latest
• Walter Bright (2/17) Dec 12 2006
• Steve Horne (5/5) Dec 16 2006 There is a HTML to LaTeX utility in sourceforge...
• BCS (2/6) Dec 16 2006 While that would get a PDF version of the /web page/, what I (and I thin...
"bls" <killing__Zoe web.de> writes:
Hi,
http://sourceforge.net/project/showfiles.php?group_id=83044

is is an open source ANSI C PDF lib. I guess available on Win. and Linux. //
lib.a.so.dll

hth and hopefully not too OT
Bjoern

Dec 11 2006
Jeff <jeffrparsons optusnet.com.au> writes:
Rather than writing to PDF directly, we'd probably be better off
figuring out some DDoc macros to spit out [La]TeX, then using tex2pdf to
create a PDF. I'd imagine this would be less painful in the long-run.

bls wrote:
Hi,
http://sourceforge.net/project/showfiles.php?group_id=83044

is is an open source ANSI C PDF lib. I guess available on Win. and Linux. //
lib.a.so.dll

hth and hopefully not too OT
Bjoern


Dec 11 2006
Jeff <jeffrparsons optusnet.com.au> writes:
Come to think of it, if nobody's already working on this, I'd be willing
to take a shot. Anyone interested?

Jeff wrote:
Rather than writing to PDF directly, we'd probably be better off
figuring out some DDoc macros to spit out [La]TeX, then using tex2pdf to
create a PDF. I'd imagine this would be less painful in the long-run.

bls wrote:
Hi,
http://sourceforge.net/project/showfiles.php?group_id=83044

is is an open source ANSI C PDF lib. I guess available on Win. and
Linux. //
lib.a.so.dll

hth and hopefully not too OT
Bjoern


Dec 12 2006
Jeff wrote:
Come to think of it, if nobody's already working on this, I'd be willing
to take a shot. Anyone interested?

Feel free to start on it, the only reason I'll not doing it yet is that:
1) W hasn't distributed any source files that use only DDoc macros and
2) This is finals week here.

sometime later this week or next week, I plan to get started on a set of
macros.

Dec 12 2006
Walter Bright <newshound digitalmars.com> writes:
BCS wrote:
Jeff wrote:
Come to think of it, if nobody's already working on this, I'd be
willing to take a shot. Anyone interested?

Feel free to start on it, the only reason I'll not doing it yet is that:
1) W hasn't distributed any source files that use only DDoc macros and

I did put the doc sources up. They still have the odd use of html tags
in them, but that shouldn't impeded getting the conversion macros worked
out.

2) This is finals week here.

sometime later this week or next week, I plan to get started on a set of
macros.


Dec 12 2006
Walter Bright wrote:
BCS wrote:

Jeff wrote:

Come to think of it, if nobody's already working on this, I'd be
willing to take a shot. Anyone interested?

Feel free to start on it, the only reason I'll not doing it yet is that:
1) W hasn't distributed any source files that use only DDoc macros and

I did put the doc sources up. They still have the odd use of html tags
in them, but that shouldn't impeded getting the conversion macros worked
out.

I guess I could do a few conversions. I was kinda hoping to get a
"official" version to work with, but oh well. If I get any conversion
done, I'll post the converted version for you and anyone else to use.

p.s. If anyone has converted any of the files, I would like to get a
copy of it.

Dec 12 2006
Walter Bright <newshound digitalmars.com> writes:
BCS wrote:
Walter Bright wrote:
I did put the doc sources up. They still have the odd use of html tags
in them, but that shouldn't impeded getting the conversion macros
worked out.

I guess I could do a few conversions. I was kinda hoping to get a
"official" version to work with, but oh well. If I get any conversion
done, I'll post the converted version for you and anyone else to use.

p.s. If anyone has converted any of the files, I would like to get a
copy of it.

Just pick one or two of the files to develop the technique. Once that
works, we can fix the rest.

Dec 13 2006
Walter Bright wrote:

Just pick one or two of the files to develop the technique. Once that
works, we can fix the rest.

Here is the first attack

PDFs here:

http://www.webpages.uidaho.edu/~shro8822/type.pdf

The table environment is proving hard to deal with. Also, it's looking
like Ddoc is going to need some sort of find-and-replace for escaping
special strings (think SED).

and here:

http://www.webpages.uidaho.edu/~shro8822/glossary.pdf

Dec 14 2006
Walter Bright <newshound digitalmars.com> writes:
BCS wrote:
Here is the first attack

It's a good start. If you can write up the roadblocks you're
encountering, I can try and figure out a way to deal with them.

Dec 14 2006
Walter Bright wrote:
BCS wrote:

Here is the first attack

It's a good start. If you can write up the roadblocks you're
encountering, I can try and figure out a way to deal with them.

The problem for tables is that TeX defines tables sizes with a syntax
like this

\begin{table}[llll]
% a table with 4 col.
....
\end{table}

the string that needs to be inserted into the template is the sequence
of "l", for which there needs to be one for each col. Some sort of
translation from "4" to "llll" is needed.

---

My first thought on how to do this is to to have a few special case
macros that are implemented inside the compiler. For instance the "4" ->
"llll" mapping would be easy to do in D:

"$(REPEAT_STRING l 4)" ==> repeat_string(["l", "4"]) ==> "llll" char[] repeat_string(char[][] args) { int l = args[0].length; int c = atoi(args[1]); char[] ret = new char[l*c]; for(int i=0; i<c; i++) ret[i*l..(i+1)*l] = args[0]; return ret; } ------- Another problem that comes up is the need to escape special character sequences. Some sort of sed like rule that would be applied to all raw text from the input file would be quite adequate. source.d:$(BF hello_world $(SUB earth)) tex.ddoc: SUB=_{$0}
BF={\bf $0} s/_/\_/ output.tex: {\bf hello\_world _{earth}} ------- Another problem that showed up (cosmetic in this case) was that in some cases the text inside of a macro ended in a \n and caused things to look something like this: foo(); {\color{green} // comment1 } bar(); {\color{green} // comment2 } rather than the preferred: foo(); {\color{green} // comment1} bar(); {\color{green} // comment2} It would be nice to be able to isolate the end of the string if it is a newline. An off-the-cuff solution would be to have "$-" or some such be
any and all trailing newlines. Then something like this could be used:

COMMENT=$(GREEN$0)$- However this would require that either those newlines be striped from$0
when $- is used, or that a form of$0 be created that always does the
stripping (maybe $-0)  Dec 14 2006 Bill Baxter <dnewsgroup billbaxter.com> writes: BCS wrote: Walter Bright wrote: BCS wrote: Here is the first attack It's a good start. If you can write up the roadblocks you're encountering, I can try and figure out a way to deal with them. The problem for tables is that TeX defines tables sizes with a syntax like this \begin{table}[llll] % a table with 4 col. .... \end{table} the string that needs to be inserted into the template is the sequence of "l", for which there needs to be one for each col. Some sort of translation from "4" to "llll" is needed. I'm pretty certain you could write a TeX macro to do that. Don't ask me how though. :-) Then DDoc macro would spit out something like \some_els{4}, which would then be processed by a LaTeX macro into 'llll'. Supposedly TeX is a Turing complete programming language, so it should be possible. Just maybe not fun. But in the end it would probably easier to have ddoc spit out some sort of meta-TeX, and use a perl/python/ruby/D script to grep through the result for special commands. I.e. you could have the DDoc macro spit out \begin{table}[ 'l'*4 ] ... \end{table} And use python/perl to grep for all ... patterns and run eval() on the text it finds there. Of course I understand the desire to make DDoc capable of doing this on its own, but DDoc macros will probably never be a full-fledged programming language, so at some point you just have to give up and use something that is. In fact you could argue that going DDoc->TeX->pdf is already such a situation. Why not DDoc->ScriptyLanguage->TeX->pdf? --bb  Dec 14 2006 Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes: Bill Baxter wrote: BCS wrote: The problem for tables is that TeX defines tables sizes with a syntax like this \begin{table}[llll] % a table with 4 col. .... \end{table} the string that needs to be inserted into the template is the sequence of "l", for which there needs to be one for each col. Some sort of translation from "4" to "llll" is needed. I'm pretty certain you could write a TeX macro to do that. Don't ask me how though. :-) Then DDoc macro would spit out something like \some_els{4}, which would then be processed by a LaTeX macro into 'llll'. Ooh, using TeX instead of DDoc for this is something I hadn't considered. Too bad I suck at TeX beyond basic markup :(. Supposedly TeX is a Turing complete programming language, so it should be possible. Just maybe not fun. It only needs to be done once though... Any TeX gurus in this newsgroup?  Dec 14 2006 Bill Baxter <dnewsgroup billbaxter.com> writes: Frits van Bommel wrote: Bill Baxter wrote: BCS wrote: The problem for tables is that TeX defines tables sizes with a syntax like this \begin{table}[llll] % a table with 4 col. .... \end{table} the string that needs to be inserted into the template is the sequence of "l", for which there needs to be one for each col. Some sort of translation from "4" to "llll" is needed. I'm pretty certain you could write a TeX macro to do that. Don't ask me how though. :-) Then DDoc macro would spit out something like \some_els{4}, which would then be processed by a LaTeX macro into 'llll'. Ooh, using TeX instead of DDoc for this is something I hadn't considered. Too bad I suck at TeX beyond basic markup :(. Supposedly TeX is a Turing complete programming language, so it should be possible. Just maybe not fun. It only needs to be done once though... Any TeX gurus in this newsgroup? I spent a few minutes searching the web (yet again) for decent documentation on writing TeX/LaTeX macros, and (yet again) came up with nothing useful. The only book I have (Lamport's LaTeX book) is also similarly useless. That's why I say it may be easier in the end to just go to an external language. At least I know I could whip up something in Python that would take me less time to do that getting that one dumb macro working in TeX. :-) --bb  Dec 14 2006 "Christian Kamm" <kamm nospam.de> writes:  I'm pretty certain you could write a TeX macro to do that. This should do the trick: \def\replicate#1#2{\ifnum#1>0 #2% \expandafter\replicate\expandafter{\number\numexpr#1-1}{#2}\fi} Used as \replicate{4}{l}. I found this snippet - written by David Kastrup - in "Pearls of TEX Programming" (2005). Christian  Dec 14 2006 Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes: BCS wrote: Walter Bright wrote: Just pick one or two of the files to develop the technique. Once that works, we can fix the rest. file:///home/urxae/tmp/ddoc_tex/tex.ddoc Here is the first attack PDFs here: http://www.webpages.uidaho.edu/~shro8822/type.pdf The table environment is proving hard to deal with. Also, it's looking like Ddoc is going to need some sort of find-and-replace for escaping special strings (think SED). and here: http://www.webpages.uidaho.edu/~shro8822/glossary.pdf I've been messing around with this a bit. Attached you'll find an updated tex.ddoc. Tables are now actually tables (not just a giant blob of text :)), and section headers are now properly in \section and \subsection. The table handling is far from perfect, though; columns are hard-coded to a maximum of 3 colums, each 5cm wide. Does anyone know how to get HTML-like auto-wrapping cells in latex, without having to explicitly specify their width? Or is this not possible? By the way, there's a missing '$' in the ulong row of the table at the
top of type.d.

Walter Bright wrote:
BCS wrote:
Here is the first attack

It's a good start. If you can write up the roadblocks you're
encountering, I can try and figure out a way to deal with them.

Well, it might be handy to have a way to repeat a character N times,
with N given by a macro parameter.
Then the table macro could accept a number-of-columns argument,
generalizing it to any number of columns.

Dec 14 2006
Frits van Bommel wrote:

Tables are now actually tables (not just a giant blob
of text :)),

I just didn't bother because I couldn't to it "right".

and section headers are now properly in \section and
\subsection.

Thanks.

OTOH maybe the whole things should be a chapter and imported/include
from some other document. The whole thing could then be done as a book.
Whatever, that's would just be another tex_book.ddoc file.

[...]
By the way, there's a missing '$' in the ulong row of the table at the top of type.d. oops. Maybe there should be a dsource project for DDoc macro sets?  Dec 14 2006 Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes: BCS wrote: Frits van Bommel wrote: and section headers are now properly in \section and \subsection. Thanks. The loose word at the top with a trailing comma was just too ugly to let it stand, and it was an easy fix... OTOH maybe the whole things should be a chapter and imported/include from some other document. The whole thing could then be done as a book. Whatever, that's would just be another tex_book.ddoc file. Yeah, maybe that's better. I didn't do that mostly because it was already \documentclass{article} and I'm lazy ;). Anyway, it'd be easy to fix, just change the document class to book, s/section/chapter/, s/subsection/section/ and probably add a title page and table of contents in the DDOC macro. Maybe there should be a dsource project for DDoc macro sets? Perhaps, if there's enough interest. Personally, it just bothered me that there was such a huge block of text that should've been a table, so I 'fixed' it. I think I probably won't be contributing a lot to this project, since I'm perfectly OK with HTML docs...  Dec 14 2006 "Christian Kamm" <kamm nospam.de> writes:  Does anyone know how to get HTML-like auto-wrapping cells in latex, without having to explicitly specify their width? Or is this not possible? The tabularx package might do what you want: http://www.cs.ualberta.ca/~c603/latex/tabularx.pdf It requires specifying the width of the table on creation, but adds the column-type 'X' that automatically expands to the maximum width. Christian  Dec 14 2006 Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes: Christian Kamm wrote: Does anyone know how to get HTML-like auto-wrapping cells in latex, without having to explicitly specify their width? Or is this not possible? The tabularx package might do what you want: http://www.cs.ualberta.ca/~c603/latex/tabularx.pdf It requires specifying the width of the table on creation, but adds the column-type 'X' that automatically expands to the maximum width. Unfortunately, it seems to default[1] to all 'X' columns having the same width. This looks kind of bad with the table in types.d, where the first column contains things like 'void', 'int' and 'float', and the other two columns contain somewhat longer texts... Another problem is that this doesn't play nice with your other suggestion: a \replicate in the second argument of tabularx yields the message "! Package array Error: Illegal pream-token (\replicate): c' used." and no output file :(. Is there any way to expand this before it's seen by the tabularx environment? [1]: It's seems that it's possible to specify the relative widths, but that's also problematic as DDoc doesn't know what they should be, so using that would probably require yet another extra parameter to the macro.  Dec 15 2006 "Christian Kamm" <kamm nospam.de> writes:  Unfortunately, it seems to default[1] to all 'X' columns having the same width. The package 'tabulary' seems to do some weighting between column sizes. It does not work with \replicate either though. Is there any way to expand this before it's seen by the tabularx environment? Probably, but I don't know how. It only seems to work as a column specifier for the native tabular and tabular* environments. Even just using the newer ones from array.sty results in this error. Christian  Dec 15 2006 "Christian Kamm" <kamm nospam.de> writes:  Is there any way to expand this before it's seen by the tabularx environment? I found it! (in the documentation of array.sty) *{N}{string} is expanded to n-times string, so |*{3}{L|} works for the table of types when using tabulary. Finally! :) Christian  Dec 15 2006 BCS <spamdump pathlink.com> writes: Thanks all for the help! I'm no TeX grue, I just use the stuff. I'll be trying the stuff posted soon. BTW I have about 15 files converted to DDoc but a little more than half of them need find/replace tweaking to escape things like "size_t" -> "size\_t". Anyway, things progress!  Dec 15 2006 Frits van Bommel <fvbommel REMwOVExCAPSs.nl> writes: BCS wrote: Thanks all for the help! I'm no TeX grue, I just use the stuff. I'll be trying the stuff posted soon. I've updated my tabularx code to use tabulary, result is attached. I've also made tables with lines, but it seems tabulary doesn't work quite right with \texttt in a column; the two longest items in type.d's first table get a line through the last character :(. I used a bit of a hack to get horizontal lines to work right. This was needed because my TD macro appends a & at the end of the text, so an extra column needs to be generated. The TABLE macro now (re)defines \horizline to \cline{1-$1}, i.e. a horizontal line over the first N
columns. TR then executes this command.
BUG: this probably breaks nested tables unless they use the same number
of columns :(.

BTW I have about 15 files converted to DDoc but a little more than half of them
need find/replace tweaking to escape things like "size_t" -> "size\_t". Anyway,
things progress!

Yeah, I imagine that automatic sed-like replacement you proposed to
Walter would be quite handy there...

Dec 15 2006
version latest

http://www.uidaho.edu/~shro8822/ddoc.zip

Include about 15 converted files. tex.ddoc doesn't (yet) contain Frits
van Bommel's work. I'll probably merge that in latter. There is an
updated doc.ddoc that has some macros added to make the HTML version work.

WARNING: the makefile works (on Linux) but more than half of the .tex
files won't work because of un-escaped special characters

Dec 15 2006
Walter Bright <newshound digitalmars.com> writes:
Feel free!

Jeff wrote:
Come to think of it, if nobody's already working on this, I'd be willing
to take a shot. Anyone interested?

Jeff wrote:
Rather than writing to PDF directly, we'd probably be better off
figuring out some DDoc macros to spit out [La]TeX, then using tex2pdf
to create a PDF. I'd imagine this would be less painful in the long-run.

bls wrote:
Hi,
http://sourceforge.net/project/showfiles.php?group_id=83044

is is an open source ANSI C PDF lib. I guess available on Win. and
Linux. //
lib.a.so.dll


Dec 12 2006
Steve Horne <stephenwantshornenospam100 aol.com> writes:
There is a HTML to LaTeX utility in sourceforge...

HTML to LaTeX

http://sourceforge.net/projects/htmltolatex/

--
Remove 'wants' and 'nospam' from e-mail.

Dec 16 2006
BCS <f d.c> writes:
Steve Horne Wrote:

There is a HTML to LaTeX utility in sourceforge...

While that would get a PDF version of the /web page/, what I (and I think
others) are trying to get is a PDF version of the /D documentation/.
`
Dec 16 2006