Skip to content

Rendered examples in documentation #11

Description

@kildom

Add plugin to markdown that shows rendered examples:

Example of `<b>` tag:

<!-- @image:bold -->
` ` ` xml
Example of <b>bold</b>.
` ` `
<!-- @end -->

The result is:

![bold](@image:bold)

Inline preview:
` ` ` xml
Example of <b>bold</b>.
` ` `
<!-- @preview -->

The plugin will do:

  1. Create DocTML from code (wrap with <document> if needed)
  2. Convert DocTML -> docx
  3. Convert docx -> pdf (with python converter)
  4. Convert pdf -> svg (with https://mupdf.readthedocs.io/en/latest/mutool-convert.html#mutool-convert)
  5. If one page:
    • convert pdf -> temporary png (with mutool)
    • detect bounding box (just top and bottom, left and right should be on entire page)
    • if small bounding box compared to entire page (e.g. h < w), then set svg viewBox to bounding box plus borders (crop)
  6. Put image where needed:
    • if inline: combine with code block
    • if non-inline: put as normal image
    • if cropped: use entire width
    • if not cropped: show page miniatures, expand on click

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationenhancementNew feature or request

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions