jgm / peg-markdown

An implementation of markdown in C, using a PEG grammar
Other
696 stars 140 forks source link

New extension: strike through with two tildes #12

Closed rekado closed 11 years ago

rekado commented 12 years ago

This patch adds support for strike-through markup as used on github.

Example:

This is ~~good~~ bad. This is good bad.

rekado commented 12 years ago

As this is an extension I could disable this by default and define EXT_STRIKE.

jgm commented 12 years ago

Yes, that would be good.

+++ rekado [Oct 26 12 18:38 ]:

As this is an extension I could disable this by default and define EXT_STRIKE.

-- Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y6848DAslDCyjnQ6q-QyN4VMN9vqr68a8qX6-yXyF69AZxw.gif]

References

  1. https://github.com/jgm/peg-markdown/pull/12#issuecomment-9831552
rekado commented 12 years ago

Done. The extension can be enabled with EXT_STRIKE (--strike in the executable).

jgm commented 12 years ago

I'm reluctant to merge this yet, as it does not implement output for strikeout in all of the output formats supported... Could you add support for the other formats?

rekado commented 12 years ago

For LaTeX output the ulem package is required. Is print_latex_element_list the right place to put package dependencies?

For groff, a macro needs to be defined; I guess this could be output first with print_groff_mm_element_list before any element is printed. This is the macro as defined here.

.de ST
.nr ww \w'\\$1'
\Z@\v'-.25m'\l'\\n[ww]u'@\\$1
..
.
This is
.ST "a test"
an actual emergency!

It should be easy to add it to the ODF output, so I'm going to do that first.

rekado commented 12 years ago

The odf header and footer are added in print_element_list, so I'll add any additional headers for groff and LaTeX there, too.

rekado commented 12 years ago

I've added strike-through support for groff output when rendering to the Postscript device; it should also work in edge cases.

LaTeX support has also been added.

rekado commented 11 years ago

Is there anything else in the way of merging this?

jgm commented 11 years ago

Can latex \usepackage commands occur in the document body? I thought they had to be in the preamble, before \begin{document}.

rekado commented 11 years ago

Is the output of ./markdown -x --to=latex supposed to be injected into the document section of an existing LaTeX document or is the output supposed to be processed as is? I assumed the latter.

jgm commented 11 years ago

No, the former.

+++ rekado [Mar 28 13 06:37 ]:

Is the output of ./markdown -x --to=latex supposed to be injected into the document section of an existing LaTeX document or is the output supposed to be processed as is? I assumed the latter.

-- Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y684-0aMJ6ADpiu7R8lfUr7nV1G5WZrj3BkFNOFEFnIYM_Y.gif]

References

  1. https://github.com/jgm/peg-markdown/pull/12#issuecomment-15588581
rekado commented 11 years ago

Well, then it's not going to work. I don't know any (non-hackish) way to strike out text in LaTeX without adding this package, and it would have to be added to the preamble.

Do you want me to remove strike-through support for LaTeX then?

jgm commented 11 years ago

I don't really have much objection to leaving it in, and documenting what is needed in the preamble in the README.

+++ rekado [Mar 28 13 20:09 ]:

Well, then it's not going to work. I don't know any (non-hackish) way to strike out text in LaTeX without adding this package, and it would have to be added to the preamble.

Do you want me to remove strike-through support for LaTeX then?

-- Reply to this email directly or [1]view it on GitHub. [xJAuenYDiIoVt3LF3y684-0aMJ6ADpiu7R8lfUr7nV1G5WZrj3BkFNOFEFnIYM_Y.gif]

References

  1. https://github.com/jgm/peg-markdown/pull/12#issuecomment-15627093
rekado commented 11 years ago

I have...