Skip to content
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

Add a mechanism for extending the Markdown reader and writer #143

Merged
merged 12 commits into from
Jun 27, 2022

Conversation

Witiko
Copy link
Owner

@Witiko Witiko commented Jun 26, 2022

Closes #138.

Tasks

  • Prepare reader for extension:
    • Move parsers upvalue and larsers local to reader->parsers.
    • Move syntax local to reader->syntax.
    • Move writer local to reader->writer.
    • Move parse_*(...) locals to reader->parser_functions.parse_*(...).
  • Prepare a simple extension for tables:
    • Create a extensions.table(captions) function.
    • Extract table-specific code from writer to extensions.table.extend_writer(writer).
    • Extract table-specific methods from reader to extensions.table.extend_reader(reader).
    • Add reader->apply_extension(extension) method that will call extensions.table.extend_reader(self) and extensions.table.extend_writer(self.writer).
    • In new(options), react to options.pipeTables and options.tableCaptions by calling reader->apply_extension(...).
  • Prepare extensions for all remaining options:
    • Options fencedCode and blankBeforeCodeFence.
    • Options citations and citationNbsps.
    • Options contentBlocks and contentBlocksLanguageMap.
    • Option definitionLists.
    • Options jekyllData and expectJekyllData.
    • Options footnotes and inlineFootnotes.
    • Option headerAttributes.

The proposed changes will reduce the code complexity of the Lua parser and perhaps also make it possible for external code to extend Markdown, although such use would be still highly unstable due to the lack of encapsulation in the proposed implementation.

@Witiko Witiko added lua Related to the Lua interface and implementation technical debt Related to code smells and refactoring labels Jun 26, 2022
@Witiko Witiko added this to the 2.16.0 milestone Jun 26, 2022
@Witiko Witiko self-assigned this Jun 26, 2022
@Witiko Witiko force-pushed the feature/add-extension-mechanism-for-markdown branch from 7dbc396 to 52d2fce Compare June 27, 2022 13:15
@Witiko Witiko force-pushed the feature/add-extension-mechanism-for-markdown branch from 52d2fce to 71e0537 Compare June 27, 2022 13:21
@Witiko Witiko force-pushed the feature/add-extension-mechanism-for-markdown branch from 677b26b to 3b410c8 Compare June 27, 2022 14:12
@Witiko Witiko force-pushed the feature/add-extension-mechanism-for-markdown branch from 3b410c8 to 201cd7b Compare June 27, 2022 14:17
@Witiko Witiko force-pushed the feature/add-extension-mechanism-for-markdown branch 7 times, most recently from 49c111b to 33fad22 Compare June 27, 2022 17:20
@Witiko Witiko force-pushed the feature/add-extension-mechanism-for-markdown branch 4 times, most recently from 8b6bddc to 375e3a4 Compare June 27, 2022 18:19
@Witiko Witiko force-pushed the feature/add-extension-mechanism-for-markdown branch 4 times, most recently from 5f9c0f0 to 826588e Compare June 27, 2022 19:32
@Witiko Witiko force-pushed the feature/add-extension-mechanism-for-markdown branch from 826588e to 4fb4dbe Compare June 27, 2022 19:44
@Witiko Witiko force-pushed the feature/add-extension-mechanism-for-markdown branch from 3d9360d to 2709e63 Compare June 27, 2022 20:31
@Witiko Witiko force-pushed the feature/add-extension-mechanism-for-markdown branch 2 times, most recently from 52f4961 to 3d852e4 Compare June 27, 2022 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lua Related to the Lua interface and implementation technical debt Related to code smells and refactoring
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a mechanism for extending the Markdown reader and writer
1 participant