-
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
Support OpTeX #215
Comments
@olsak I can handle tasks 2–4, but I would appreciate help with task 1 (Define renderers for OpTeX). In the user manual, there is a list of all renderers in the Markdown package. We have some definitions for plain TeX (see If I can get a list of definitions such as the following, I can take it from there. \def\markdownRendererHeadingOnePrototype#1{\tit #1^^M}%
\def\markdownRendererHeadingTwoPrototype#1{\chap #1^^M}%
\def\markdownRendererHeadingThreePrototype#1{\sec #1^^M}%
% ... With correct definitions, we should be able to typeset the document \input markdown
% Options
\def\markdownOptionContentBlocks{true}%
\def\markdownOptionDebugExtensions{true}%
\def\markdownOptionDefinitionLists{true}%
\def\markdownOptionFancyLists{true}%
\def\markdownOptionHashEnumerators{true}%
\def\markdownOptionInlineNotes{true}%
\def\markdownOptionNotes{true}%
\def\markdownOptionPipeTables{true}%
\def\markdownOptionRawAttributes{true}%
\def\markdownOptionSmartEllipses{true}%
\def\markdownOptionStrikeThrough{true}%
\def\markdownOptionSubscripts{true}%
\def\markdownOptionSuperscripts{true}%
\def\markdownOptionTableCaptions{true}%
\def\markdownOptionTaskLists{true}%
% Renderer prototypes
\def\markdownRendererHeadingOnePrototype#1{\tit #1^^M}%
\def\markdownRendererHeadingTwoPrototype#1{\chap #1^^M}%
\def\markdownRendererHeadingThreePrototype#1{\sec #1^^M}%
% ...
% Example document
\fontfam[LMfonts]
\markdownInput{example.md}
\bye |
I mean that
and it will work in titles, outlines, tables of contents etc. (Something similar is impossible in LaTeX.). But we can throw away this feature of scanning to the end of line and use internal OpTeX macros for markdown package, i.e.
I'll take look to another prototypes... |
I tried to \input markdown in OpTeX but there are problems. It does \input expl3-generic and this macro file cannot be loaded in OpTeX without additional tricks. I hope that we need not to load this macro file in OpTeX, but I can mention the tricks.
Sumarry: the following code must be inserted before
|
The Markdown package exposes a Lua module, so it is definitely possible to make the OpTeX layer sit directly on top of the Lua layer unlike the ConTeXt and LaTeX layers, which sit on top of the Plain TeX + expl3 layer: This would honor the spirit of the OpTeX format (minimalistic, fast, no-nonsense). It would reduce code reuse, but that may be a good thing, because it allows us to reimagine e.g. the option-passing from TeX to Lua. Here is how you could use the Markdown package via Lua in OpTeX: \directlua{
local ran_ok, kpse = pcall(require, "kpse")
if ran_ok then kpse.set_program_name("luatex") end
local convert = require("markdown").new()
function markdown(input)
local output = convert(input)
tex.print(output)
end
}
\let\markdownRendererDocumentBegin\relax
\def\markdownRendererEmphasis#1{{\em #1}}
\let\markdownRendererDocumentEnd\relax
\directlua{ markdown"Hello *world*!" }
\bye |
This is useful to know and we may want to forward this to https://github.com/latex3/latex3, so that |
It is amazing! If there is a list of all control sequences generated by the convert Lua function (like |
All % tricks needed to load expl3-generic.tex package
\directlua{
function luatexbase.new_luafunction(name)
return \string#lua.get_functions_table() + 1
end }
\mathsboff
\def\newread {\_newread}
\def\newwrite {\_newwrite}
\slet{e@alloc@ccodetable@count}{_catcodetablealloc}
\input markdown
% list all renderers and the number of parameters that they accept
\begitems
\ExplSyntaxOn
\seq_map_inline:Nn
\g__markdown_renderers_seq
{
\tl_set:Nn
\l_tmpa_tl
{ #1 }
\regex_replace_once:nnN
{ ^. }
{ \c { bslash } markdownRenderer \c { str_uppercase:n } \cB\{ \0 \cE\} }
\l_tmpa_tl
\prop_get:NnN
\g__markdown_renderer_arities_prop
{ #1 }
\l_tmpb_tl
* \l_tmpa_tl{}~(accepts~\l_tmpb_tl{}~parameters)
}
\ExplSyntaxOff
\enditems
\bye Here is the output of running OpTeX on the above source code with the current source code from branch Most renderers have a fixed number of parameters and have an obvious default definition, such as
|
I tried first attempt to set OpTeX macros with markdown package. But I don't understand many things, the
|
See the documentation of option
See also the documentation of bullet item renderers:
See also the CommonMark spec. Since non-tight lists contain bullet items with multiple paragraphs, it may be a good idea to add vertical spaces not just around the list but also between the individual items. Here is how the above example is rendered in LaTeX by default: |
The plain TeX layer changes the catcodes of |
@olsak I am planning to tackle OpTeX support in the version 2.23.0 of the Markdown package (to be released at the end of April) and discuss it briefly at TUG 2023. |
@olsak In #292, I have just added a minimal demo of using OpTeX with the Markdown package to file This demo will be included in Markdown 3.0.0, to be released later this month and to be presented at TUG 2023. This is a minimal viable product that mainly includes base markdown elements and not syntax extensions such as tables, tickboxes, or notes. Support for more syntax extensions can be added as follows:
I have scheduled these additions to the August 2023 release. Contributions are appreciated. |
The Markdown package currently supports plain TeX, LaTeX, and ConTeXt. We should add support for further formats such as Petr @olsak's OpTeX.
The text was updated successfully, but these errors were encountered: