Den tis 4 okt. 2022 11:52Albert Krewinkel skrev: > > BPJ writes: > > > Den mån 19 sep. 2022 14:51 Albert Krewinkel < > >> albert+pandoc-9EawChwDxG8hFhg+JK9F0w@public.gmane.org> skrev: > >> > >> Extensions have to be passed as part of the format string, e.g., > >> > >> pandoc.read(source, 'markdown-tex_math_dollars') > >> > >> I'm not entirely happy with this, as it means that any extensions > >> passed via a ReaderOptions object will be ignored. > >> > >> -- this may seem like it should disable all extensions, > >> -- but the ReaderOptions `extensions` field is ignored. > >> -- The default 'markdown' extensions will be used instead. > >> pandoc.read(src, 'markdown', {extensions = {}}) > >> > >> Ideas to improve this would be most welcome. > > > > I would just change it to not ignore reader options, and throw an > > error if the format string and the reader options contradict each > > other (except for empty table = no extensions and no extensions in > > string = default extensions). And better hurry before someone starts > > to rely on reader options being ignored! :-) > > I believe that this has already become the expected behavior, so I'd be > very hesitant to break it. How about this approach: The format specifier > can currently only be a string. We change this to accept either a > string, or a table with the extensions being given in separate fields. > E.g. > > -- extensions relative to default for format > { format = 'markdown', > , disable = {'markdown_in_html_blocks'}, > , enable = {'emoji'}, > } > I like this! > or > > -- absolute set of extensions > { format = 'docx', > , extensions = {'auto_identifiers', 'styles', 'citations'} > } > This `extensions` field would be identical to the `enable` field, wouldn't it, or would it mean that all default extensions not explicitly mentioned in it would be disabled? And what would happen if someone uses it together with `disable` and/or `enable`; which would be ignored, or would it be an error condition? > If the function is called with either a string or a table that has > explicit info on extensions, then the ReaderOptions extensions are > overridden. If the table has no info about extensions, then we use the > ReaderOptions. > If the format can be a table as described I think it is better to always ignore the format/extension info in the ReaderOptions — and say so clearly in the documentation! > It might still be a little confusing, as > > pandoc.read(src, 'markdown', opts) -- default Markdown extensions > > will behave differently than > > pandoc.read(src, {format: 'markdown'}, opts) -- extensions in opts > > Extensions are closer to formats than to reader options, conceptually. > It seems sensible to tie them to formats. Agreed. But maybe there is a better > way? > I think this would be fine. Also I assume that `pandoc.write()` would behave analogously? > -- > Albert Krewinkel > GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124 > > -- > You received this message because you are subscribed to the Google Groups > "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/87v8oz3ohm.fsf%40zeitkraut.de > . > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/CADAJKhCg3rMk%2B0fJBOcte32BVh2c9tYQHa57DEGHdyAz2u7%2BkQ%40mail.gmail.com.