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

Draft: Add an "allowHTML" feature for Markdoc #7582

Closed
wants to merge 26 commits into from
Closed

Draft: Add an "allowHTML" feature for Markdoc #7582

wants to merge 26 commits into from

Conversation

alex-sherwin
Copy link
Contributor

@alex-sherwin alex-sherwin commented Jul 5, 2023

Changes

  • Adds an allowHTML option for the @astrojs/markdoc integration which enables HTML tokenization/rendering in Markdoc markup

Testing

With extensive unit tests on parsed HTML DOM elements

Docs

@changeset-bot
Copy link

changeset-bot bot commented Jul 5, 2023

🦋 Changeset detected

Latest commit: 10e0eec

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Jul 5, 2023
Copy link
Contributor

@bholmesdev bholmesdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, very impressed with the thorough documentation and unit testing. Thanks for this! I've left some comments below, and have some general comments to address:

  • Folder structure: I'm not sure html belongs in extensions/, since it isn't applied using the extends configuration option. I think we can move html/ to the base src/ directory. I also think we can remove the 3rd-party/ directory; a code comment at the top denoting the source should be sufficient.
  • Attributing MIT licensed code: Speaking with core, I don't think "taken from" is the right verbage for these comments. I'm discussing with core how we can best attribute external code. I'll follow-up with a better answer!

@bholmesdev
Copy link
Contributor

Update: Here's our recommendation for citing external code!

When your licensed code only lives in a single file, I'd do a comment in that one file instead. /** @license MIT ${COPY-PASTE-THE-ENTIRE-LICENSE-HERE} */
either at the top of the file, or as close to the one snippet of code as possible.

This may seem excessive, though it makes guidelines clear for code usage. I'd use this in the files under 3rd-party/ and the react transforms.

@alex-sherwin alex-sherwin changed the title Draft: Add an "enableHTML" feature for Markdoc Draft: Add an "allowHTML" feature for Markdoc Jul 7, 2023
alex-sherwin and others added 25 commits July 7, 2023 10:49
This uses htmlparser2 to perform a pure token transform/mutation
on the markdown-it tokens, replacing the original raw HTML string
tokens with a richer set of tokens per HTML node, and in the process
Markdoc tags are interleaved in the resulting token graph at the
appropriate locations

This removes the legacy config of the @astrojs/markdoc integration
entirely (suggested by @bholmesdev) and introduces a new type for
options to be specified in the astro config, initially, with just the new
"enableHTML" option

When "enableHTML" is *not* enabled (the default), the behavior
of the entire @astrojs/markdoc integration should remain functionally
equivalent to before this change
also:

* cleaned up " to ' for astro project preferred linting
* made the html rendering test fixture use a dynamic path
Co-authored-by: Bjorn Lu <[email protected]>
Co-authored-by: Sarah Rainsberger <[email protected]>
Co-authored-by: Sarah Rainsberger <[email protected]>
* move out of extensions dir, remove export
* cdata handling changes
* inline license from third party code
* cleanup test class copy of HTML output
* remove // third party indicators for imports (clarification: not third party code, just a indicator this group of imports is third party)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* Runtime environment variables docs for node integration

* Update packages/integrations/node/README.md

Co-authored-by: Reuben Tier <[email protected]>

* final fixes

---------

Co-authored-by: Reuben Tier <[email protected]>
* docs: add docs link to markdoc error

* docs: add named exports guide to README

* chore: changeset

* edit: no like so

Co-authored-by: Chris Swithinbank <[email protected]>

* edit: exposed as named exports

Co-authored-by: Chris Swithinbank <[email protected]>

---------

Co-authored-by: bholmesdev <[email protected]>
Co-authored-by: Chris Swithinbank <[email protected]>
@github-actions github-actions bot added pkg: svelte Related to Svelte (scope) pkg: vue Related to Vue (scope) pkg: example Related to an example package (scope) 🚨 action Modifies GitHub Actions pkg: create-astro Related to the `create-astro` package (scope) pkg: astro Related to the core `astro` package (scope) labels Jul 7, 2023
@alex-sherwin
Copy link
Contributor Author

I really screwed up this branch with a rebase to fix my commit author info :)

I'll leave this repo up for short-term posterity but will open up a PR from a clean branch

@bholmesdev
Copy link
Contributor

@alex-sherwin agh, just happened to me on a Markdoc release too. No problem, link when it's available!

@alex-sherwin
Copy link
Contributor Author

alex-sherwin commented Jul 7, 2023

@bholmesdev New PR is ready: #7597

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 action Modifies GitHub Actions pkg: astro Related to the core `astro` package (scope) pkg: create-astro Related to the `create-astro` package (scope) pkg: example Related to an example package (scope) pkg: integration Related to any renderer integration (scope) pkg: svelte Related to Svelte (scope) pkg: vue Related to Vue (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants