-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve ConTeXt interface #17
Comments
Hi, Do you have any drafts on this? Any tests? Any timeline? Any first goals? Do you they mean by the following the same as
Best regards, Sami |
Hi,
There are no tests and no timeline. There is currently minimal syntactic sugar for ConTeXt on top of the plain TeX interface ( As I stated in the original post, I rarely use ConTeXt, so I don't really have a feel for the ConTeXt philosophy and syntax conventions. Therefore, I am looking for a draft of the syntax and how it would be best implemented using the existing ConTeXt mechanisms.
Sure, these are equivalent from the viewpoint of ConTeXt. |
@mojca, I recall that you proposed a more complete ConTeXt syntax extension for the Markdown package after the TUG@BachoTeX 2017 conference. Have you noticed any desire to integrate the package more tightly with ConTeXt or other recent relevant feedback from the ConTeXt users? |
@Witiko I have never looked at the package in detail, but I can help with the ConTeXt interface. Can you give more details on what you are looking at. From the discussion in this thread, I understand that the current interface is driven using macros. Changing that to keyword interface should be straight forward. Is there a document where all the interface options are described? In general, if you have any questions on anything related to ConTeXt, feel free to ping me. |
@adityam Thank you for your response. In LaTeX, users can configure the package when loading the package: \documentclass{article}
\usepackage[hybrid, pipeTables]{markdown}
...
\begin{document}
... They can also configure the package using the ...
\markdownSetup{
hybrid,
pipeTables,
renderers = {
table = { ... },
},
}
... They can also configure the package locally for every piece of markdown code: ...
\begin{markdown}
$\sqrt{-1}$ *equals* $i$
\end{markdown}
\begin{markdown*}{hybrid}
$\sqrt{-1}$ *equals* $i$
\end{markdown*}
... For ConTeXt, there is no such support and the users have to rely on redefining macros, which seems out-of-place in a ConTeXt document: \usemodule[t][markdown]
\starttext
\startmarkdown
$\sqrt{-1}$ *equals* $i$.
\stopmarkdown
\def\markdownOptionHybrid{true}
\startmarkdown
$\sqrt{-1}$ *equals* $i$.
\stopmarkdown
\stoptext I am looking for a suggestion as to how things should look, so that the interface is more friendly to the ConTeXt users.
Thanks again, much appreciated. |
For ConTeXt one would probably want to use something like this \usemodule
[markdown]
\setupmarkdown
[hybrid=off,
tables=on]
\starttext
\startmarkdown
$\sqrt{-1}$ *equals* $i$.
\stopmarkdown
\startmarkdown[hybrid] % or hybrid=on
$\sqrt{-1}$ *equals* $i$.
\stopmarkdown
\stoptext But there are some other options that could use other tricks. I've seen the @adityam: There is a long document with documentation describing all options in detail. It's unlikely that I would manage to sit down and spend any reasonal amount of time for this myself, in particular given that I'm unlikely to ever use MarkDown myself (I hardly do any typesetting at all these days to be honest). I could review / provide feedback. But @adityam and some others like Wolfgang Schuster are big experts and can help with some excellent examples of good coding practice for ConTeXt. |
@mojca Thank you, this is much appreciated.
Not being too smart is the main philosophy behind the Markdown package (as opposed to Pandoc and other tools). The text
# heading
other text will be parsed as follows:
or as follows:
The Markdown spec is ambiguous in this regard, so we provide an option to choose the parser flavor. In general, most options control the parser, not the way Markdown elements are rendered. For this, there are renderers (redefinable TeX commands to which the Markdown elements expand to) and, indeed, the standard formatting setup of the ConTeXt format. |
@adityam: There is a long document with [documentation](http://mirrors.ctan.org/macros/generic/markdown/markdown.html) describing all options in detail.
Thanks. I will go over this and try to understand all the options and then
come back with suggestions of an interface that will fit with ConTeXt style.
|
Oh, I'm sorry. Yes, then this option makes perfect sense. I thought it was about how output was supposed to look like. |
I am still trying to understand the overall structure and hope you don't mind me asking clarifying questions here. I am assuming that in ConTeXt, anyone running the module will be using MkIV (luatex engine).
|
The main markdown document could be stored in-memory when LuaTeX is used. However, the code blocks markdown renderer expects a filename with the code block as an argument; these auxiliary files would be difficult to get rid of without breaking the established interface. Note that auxiliary files can be useful. As an example, the Czech typography forbids a line ending with a non-syllabic preposition. To address this issue, the vlna program can be used to add a non-breaking space after all non-syllabic prepositions in a text file. With auxiliary files, you can easily use the
Yes, there is the Lua interface.
There is a minor speed penalty, since a hash table is used instead of local variables. This change was necessary for us, because there is an upper limit on the number of local variables in Lua, which we hit.
You will likely want to reuse some parts of
We have a rich set of unit tests. |
OK. I'll stick with this for now.
I meant something that does not create temp files. But I'll not go down that path for now.
Perhap. For most of the features, I think that it is better to follow the ConTeXt style for defining (and therefore changing) rendering options. For example, let's consider a simple ConTeXt file:
Here is a basic implmentation of the
Using high-level ConTeXt macros (\definehighlight etc) instead of low level TeX commands (\def...) etc has the advantage that (i) you get a simple key-level driven interface to change features, (e.g., to get red colored emphasis, simply add |
Not really. The auxiliary files are an early design decision, which affects the whole code base.
That is fine, but the content of the renderer definitions can be reused. |
@adityam Any progress with the interface? In your #17 (comment), there is a redefinition of \usemodule[t][markdown]
\def\markdownOptionPipeTables{true}
\def\markdownOptionTableCaptions{true}
\starttext
\startmarkdown
$\sqrt{-1}$ *equals* $i$.
\stopmarkdown
\begingroup
\def\markdownOptionHybrid{true}
\startmarkdown
$\sqrt{-1}$ *equals* $i$.
\stopmarkdown
\endgroup
\stoptext Compare with the LaTeX interface for options, which is much more compact and idiomatic: \documentclass{article}
\usepackage[pipeTables,tableCaptions]{markdown}
\begin{document}
\begin{markdown}
$\sqrt{-1}$ *equals* $i$
\end{markdown}
\begin{markdown*}{hybrid}
$\sqrt{-1}$ *equals* $i$
\end{markdown*}
\end{document} Any change towards a more compact and idiomatic ConTeXt code would be greatly appreciated! |
@adityam I would add these to the example documents, but we support ConTeXt MkII and the |
On Sun, 8 Aug 2021, Vít Novotný wrote:
> Using high-level ConTeXt macros (\definehighlight etc) instead of low level TeX commands (\def...) etc has the advantage that (i) you get a simple key-level driven interface to change features, (e.g., to get red colored emphasis, simply add `\setuphighlight[markdownRendererEmphasis][color=red]`. (ii) Generating structured outputs such as tagged-pdf and XHTML or EPUB export work out of the box.
@adityam I would add these to the example documents, but we support ConTeXt MkII and the `\definehighlight` command doesn't seem to be available in MkII.
Would it be possible to provide separate examples for MkII and MkIV. MkII has been in maintenance-only mode for almost a decade now. So, any ConTeXt user still using MkII will be an old user who is using MkII on a long-term project. Almost all ConTeXt documentation assumes that a new user is starting with either MkIV or even LMTX.
|
@adityam We can definitely fork diff --git a/examples/Makefile b/examples/Makefile
index e084a9a..548e4e2 100644
--- a/examples/Makefile
+++ b/examples/Makefile
@@ -14,13 +14,11 @@ all: $(OUTPUT)
$(MAKE) clean
# This target typesets the ConTeXt example using the Mark II format.
-context-mkii.pdf: context.tex example.tex
- cp context.tex context-mkii.tex
+context-mkii.pdf: context-mkii.tex example.tex
texexec --passon="--shell-escape --8bit" context-mkii.tex
# This target typesets the ConTeXt example using the Mark IV format.
-context-mkiv.pdf: context.tex example.tex
- cp context.tex context-mkiv.tex
+context-mkiv.pdf: context-mkiv.tex example.tex
context context-mkiv.tex
# This target typesets the LaTeX example using the pdfTeX engine. In order to include the two files in the distribution archive, the following line also needs to be updated in Line 12 in 4b89f84
For LMTX, I am waiting for it to be added to TeX Live, since typesetting example documents is part of our continuous integration. |
I added an example document for ConTeXt MkIV. |
It would be neat if we could have a % Set options of the Markdown module.
\def\markdownOptionHashEnumerators{true}
\def\markdownOptionDefinitionLists{true}
\def\markdownOptionSmartEllipses{true}
\def\markdownOptionFootnotes{true}
\def\markdownOptionInlineFootnotes{true}
\def\markdownOptionFencedCode{true}
\def\markdownOptionContentBlocks{true}
\def\markdownOptionPipeTables{true}
\def\markdownOptionTableCaptions{true}
\def\markdownOptionTaskLists{true} with this: % Set options of the Markdown module.
\markdownSetup[hashEnumerators,
definitionLists,
smartEllipses,
footnotes,
inlineFootnotes,
fencedCode,
contentBlocks,
pipeTables,
tableCaptions,
taskLists] I wonder how we could do that. |
I would recommend a slightly more context-ish syntax: ConTeXt doesn't use CamelCase a lot ... nevertheless, if you can consider
You'd need to initialize the values somewhere:
Example usage:
If you'd prefer |
... and of course, lowercase
|
@adityam Thank you, that is helpful.
Does it use snake_case then? We could still make that work automatically.
Not all options are boolean. For example, the
... that's what the LaTeX interface currently does. However, it's a pain to maintain and even moreso if we typed out everything for ConTeXt as well. Perhaps we should add runtime information about types, so that this can be automated. |
ConTeXt doesn't use snake_case either. Almost all options are single word. Another option is not to do any parsing at the TeX end. Simply pass everything as input by the user to Lua: something like ...
This is laborious, but has to be done once in each format. Then, at the lua end, you can read the value of |
Well, we can still run with that, it should be just a matter of replacing
That would be technically possible, but I see two possible concerns:
|
This issue is blocked by #124. |
The ConTeXt interface would benefit from a proper user interface such as the one LaTeX has. Being an academician first and a TeX enthusiast second, I have only had cursory exposure to ConTeXt. Therefore, I don't feel I understand the ConTeXt philosophy and syntax conventions enough to design a user interface for it. This leaves the ConTeXt users of the Markdown package with the plain TeX interface, which is not ugly per se, but which does feel out of place in a ConTeXt document.
See also the accurate description of the status quo by on the ConTeXt mailing list by @mojca:
I will appreciate any suggestions on how the user interface for ConTeXt should be redesigned to better fit in with the rest of ConTeXt and which ConTeXt mechanisms should be used to implement the suggested redesign.
The text was updated successfully, but these errors were encountered: