mixmark-io / turndown

🛏 An HTML to Markdown converter written in JavaScript
https://mixmark-io.github.io/turndown
MIT License
8.88k stars 879 forks source link

Problem with inline code #136

Closed missingtrailingcomma closed 6 years ago

missingtrailingcomma commented 8 years ago
<p><code>There is a literal backtick (`) here.</code></p>

should be converted to

``There is a literal backtick (`) here.``

Here is my solution, may be wrong :)

 
'CODE': (children, node) => {
  if (node.parentNode.nodeName === 'PRE') {
    return `\n\n    ${children.replace(/\n/g, '\n    ')}\n\n`
  }
  const modifiedChildren = children.replace(/^`/, ' `').replace(/`$/, '` ');
  return `\`\`${modifiedChildren}\`\``;
},
            
ckoppelman commented 8 years ago

I assume this is related to #81 as well.

missingtrailingcomma commented 8 years ago

@ckoppelman If I understand it right, mine and #81 are of the same problem domain but require different kinds of solutions: #81 needs proper escape while mine is to refactor the markdown syntax produced. I'd like to offer help if you identify this issue as an issue :)

ckoppelman commented 8 years ago

@love4shen - This is not my project, but I think you can submit a pull request regardless.

missingtrailingcomma commented 8 years ago

@ckoppelman Oh, sorry, my bad. Thanks!

domchristie commented 7 years ago

Sorry, I didn't fully understand the problem. I have fixed this in the turndown branch

domchristie commented 6 years ago

This will be fixed in turndown v4