Ticket #48 (new enhancement)

Opened 21 months ago

Last modified 21 months ago

Export to Latex

Reported by: andrea Owned by: deveiant
Priority: normal Milestone: New Features Post Markdown 1.0.1
Component: API Version:
Severity: normal Keywords:
Cc:

Description

It would be nice to export to latex.

This could have many uses. For example, to create high-quality PDF to use in "print this page" links.

Syntatically, the transformations would be as follows:

Heading
=======    => \section{Heading}

Heading
-------    => \subsection{Heading}

## Heading => \subsubsection{Heading}

*italic* => {\em italic}
**bold** => {\bf bold}

# links should be transformed to:
\href{url}{text}
# to have clickable links in the document

# ordered list
\begin{enumerate}
\item item1 
...
\end{enumerate}

Moreover, one should wirte the equivalent of encode_html for latex.

I have tried to do these simple changes and it is trivial. However, mine is only a fast hack to see the feasibility.

In practice, there should be some sort of separation between parsing and rendering in Bluecloth, to make this task easy to do (and above all maintenable).

I attach to this ticket the original Markdown file and the PDF produced from it.

Attachments

misc_sw.pdf (46.4 kB) - added by andrea 21 months ago.
Generated PDF
misc_sw.md (2.6 kB) - added by andrea 21 months ago.
Markdown Source

Change History

Changed 21 months ago by andrea

Generated PDF

Changed 21 months ago by andrea

Markdown Source

follow-up: ↓ 2   Changed 21 months ago by andrea

(I was sending you an email, but both your addresses @FaeireMUD.org and @devEiate.org are unreachable - at least from gmail)

I have seen that you accepted this patch:

http://deveiate.org/projects/BlueCloth/ticket/46

which goes in the right way.

If I were to design BlueCloth from scratch, I would have clearly separated the parsing and the rendering, by creating an in-memory representation of the parsed document. I'm sure that now you are thinking of doing something similar, especially if you want to support advanced syntax (e.g. tables).

In the meantime, my plan is to create an unobtrusive to_tex method. I was thinking of simply aliasing the render methods (defined by the patch in ticket 46) to the equivalent methods for TeX. This should be enough for basic support of TeX.

Is there any chance I can get read-only access to the BlueCloth repository, so that I can create a patch easily based on your current version?

in reply to: ↑ 1   Changed 21 months ago by deveiant

Replying to andrea:

If I were to design BlueCloth from scratch, I would have clearly separated the parsing and the rendering, by creating an in-memory representation of the parsed document. I'm sure that now you are thinking of doing something similar, especially if you want to support advanced syntax (e.g. tables).

Indeed. I started with a straight port from the original Perl version, with no intent other than to provide the transformation in the simplest way possible.

With all the requests for hooks into the various stages of the transformation, I'm going to have to do something similar to what you're suggesting.

Is there any chance I can get read-only access to the BlueCloth repository, so that I can create a patch easily based on your current version?

Certainly. I didn't realize the subversion URL wasn't on the front page. I've added it there, and here it is for your convenience:

svn://deveiate.org/BlueCloth/trunk

Sorry about that!

Note: See TracTickets for help on using tickets.