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

Code block language not migrated properly #15

Open
uuf6429 opened this issue Sep 26, 2022 · 0 comments
Open

Code block language not migrated properly #15

uuf6429 opened this issue Sep 26, 2022 · 0 comments

Comments

@uuf6429
Copy link

uuf6429 commented Sep 26, 2022

The turndown module is able to extract code block language defined as a class, but only when codeBlockStyle is "fenced" (which is not the default).

So for example:

const html = '<pre><code class="language-css">h1 { font-size: 20px; }</code></pre>'

(new TurndownService()).turndown(html)
// ❌ results:
//     h1 { font-size: 20px; }

(new TurndownService({ codeBlockStyle: 'fenced' })).turndown(html)
// ✅ results:
// ```css
// h1 { font-size: 20px; }
// ```

Apparently wp2storyblok, handles both cases - so it seems beneficial to use fenced style instead of indented style, to also migrate the language:

const turndownService = new TurndownService()


Side note: in my case I need it to be able to safely migrate content that is not supported in markdown (as components).
For example, say we want to migrates <iframe>s, first I convert all iframes to <pre><code class="language-sb-component-json">{"component":"iframe"....}</code></pre> and then I expand it later to a richtext component.

Of course, this could be improved or automated inside the migration module..

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

No branches or pull requests

1 participant