3

I'm using dflydev's markdown which is based on michelf's project to transform Markdown into HTML.

My site is RTL by default and I'd like to add a custom tag to allow left-aligning paragraphs,
something like:

regular text, right aligned.

<- some text that will be aligned to the left

<--
fenced text that will be aligned to the left
<--

I'm trying to build the regex pattern to catch those blocks:

  • For <- ... I have: /^<- ([^\n]+)/
  • For the fenced block I couldn't get a working pattern

I'd like to get help on the fenced block regex and on improving the one-line regex I already have.

Thanks!

2 Answers 2

0

This would match your second group:

^<--.*?<--$

For your first group I would use something like this instead:

^<-[^-][^\r\n]*?$
2
  • It matches the block content correctly, but I need to replace the whole block <-- ... <-- with the HTML <span>...</span> and the matches don't include the tags <--
    – tamir
    Dec 25, 2012 at 15:43
  • @tamir checkout my response, I updated it to include the tags
    – user1006989
    Dec 25, 2012 at 15:48
0

For your first case you can use

/^<-(.*?)$/

and get the first group.

For the second case use

/^<--(.*?)<--$/

and get the first group.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.