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

Use markdown instead of HTML in activities.yml #1147

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

zcorpan
Copy link
Member

@zcorpan zcorpan commented Dec 18, 2024

Also support code in the spec link text.

while (node = iterator.nextNode()) {
if (node.nodeType === Node.TEXT_NODE) {
continue;
function parseMarkdown(markdown, enableLinks = true) {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a fan of defaults being true. Though see below for an alternative structure.

const fragment = document.createDocumentFragment();

// Regex for either code or link (only # or https://)
const markdownPattern = enableLinks ? /(`([^`]+)`|\[([^\]]+)\]\(((?:#|https:\/\/)[^\)]+)\))/g : /(`([^`]+)`)/g;
Copy link
Member

Choose a reason for hiding this comment

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

It looks like you have two obvious phases here: link parsing and code parsing. Could that be two separate passes? That might remove the need for the argument as well.

function expandLinks(md) {
  // match then expandInline in the text chunks before appending those.
}
function expandInline(md) {
  // match /`([^`]+)`/ and maybe /\b*([^*]+)*\b/ as well.
}

Copy link
Member

Choose a reason for hiding this comment

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

Separately, you don't need the '/g' if you are parsing in chunks like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants