Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Allow custom inline style matcher #94

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

dino115
Copy link

@dino115 dino115 commented Jun 23, 2018

Hi,
first of all, thank you very much for your great work!

For my project i have to change the inline style handlers, because up to now we have used a slightly different markdown syntax. I.e. ** for bold, * for italic, and _ for underline and i have to add some additional inline styles.

So i quickly added a configuration for custom inline style matchers. You can use it in the following way:

const markdownPlugin = createMarkdownPlugin({
  customInlineMatchers: {
    BOLD: [/\*\*(.+)\*\*\s$/g, /__(.+)__\s$/g],
    ITALIC: [/\*(.+)\*\s$/g],
    UNDERLINE: [/_(.+)_\s$/g],
    CODE: [/`([^`]+)`\s$/g],
    STRIKETHROUGH: [/~~([^~]+)~~\s$/g],
    MARK: [/==(.+)==\s$/g],
  },
  features: {
    inline: [
      'BOLD',
      'ITALIC',
      'UNDERLINE',
      'CODE',
      'STRIKETHROUGH',
      'MARK',
    ],
  },
});

What do you think about this?

@dino115
Copy link
Author

dino115 commented Jun 25, 2018

Update: I've added the ability to wait for a whitespace character after the markdown applies a style to the text. To use this, you have to group the ending whitespace in the regular expression.

This is neccessary if you will use the same char in different styles. I.e. ** for bold and * for italic.

BOLD: [/\*\*(.+)\*\*(\s)$/g],
ITALIC: [/\*(.+)\*(\s)$/g],

@dino115 dino115 force-pushed the feature/customInlineStyleMatchers branch from 61e835b to 2350fb0 Compare June 25, 2018 15:18
@dino115 dino115 force-pushed the feature/customInlineStyleMatchers branch from 2350fb0 to 60407de Compare June 25, 2018 16:24
@mxstbr
Copy link

mxstbr commented Jul 5, 2018

Sorry for the slow response here—I see where you're going with this and why it'd be use, but I'm not sure I'm ready to maintain all this code we don't use 😕 I'm afraid it'll grow stale and buggy, and it won't be a good experience.

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

Successfully merging this pull request may close these issues.

None yet

3 participants