Comments (11)
The behavior of block tags would be better in a more common case - write component in multi-line:
<Foo
class="foobar"
title="baz"
/>
Check the differences here.
You'll notice that the inline one is wrapped with a <p>
tag, which might not be expected for Vue components.
In fact, they are almost the same in most cases. What you reported is one of the edge cases that the behaviors differ. If the tag is not at the beginning of the list item, everything will work as expected:
* <div/> [Example link](https://github.com/)
* foobar<div/> [Example link](https://github.com/)
The reason is that a html block at the beginning of a line somehow "terminates" the parsing of the entire line.
It looks weird indeed, but markdown-it says it is a 100%-done-right CommonMark parser, so 😑
from unplugin-vue-markdown.
There could be a solution for that, but in fact I'm also not an expert of the markdown-it parsing flow so I didn't solve it yet 😢 .
from unplugin-vue-markdown.
@manniL Good news, I think I made it at least for this case 😃
from unplugin-vue-markdown.
/cc @meteorlxy 👀
from unplugin-vue-markdown.
Well... I'd say this is kind of as expected, because we are treating vue components as html block tags, instead of inline tags. That's say this plugin is stricter than vite-plugin-md.
See the differences between inline tags and block tags:
from unplugin-vue-markdown.
Maybe we could expose an API to allow users customizing which components should be treated as inline 🤔 ?
from unplugin-vue-markdown.
This option should help with your case:
componentOptions: {
inlineTags: ['mdi-github'],
}
from unplugin-vue-markdown.
Well... I'd say this is kind of as expected, because we are treating vue components as html block tags, instead of inline tags. That's say this plugin is stricter than vite-plugin-md.
Interesting insight, thanks! Could you briefly highlight why Vue components are treated as block tags and not as inline tags "anymore" (compared to vite-plugin-md
)?
This option should help with your case:
componentOptions: { inlineTags: ['mdi-github'], }
Thanks for providing a quick workaround for that issue 👍🏻
Do you think it'd be reasonable to have a flag that automatically treats all components as inline tags? So compat with vite-plugin-md
is better (e.g. some of my slides are broken because of the switch in Slidev itself so a flag which could be set in Slidev might mitigate this issue)
from unplugin-vue-markdown.
Thanks for the detailed answer!
Would it make sense to differ between multi-line Vue components (block-level by default) and "inline" Vue components (inline-level by default) then? Sadly I'm not aware of the internals and if that's possible but this would kill two birds with one stone: No superfluous (or possibly even bug-introducing) <p>
tag around multi-line components and compat behavior (for most cases).
from unplugin-vue-markdown.
I think the behavior is acceptable and only slightly violates the CommonMark spec.
Component tags would behave differently from block & inline tags:
block tags
Terminate the line:
<!-- input -->
<div /> [link](link)
<!-- output -->
<div /> [link](link)
inline tags
As normal inline content being wrapped with <p>
:
<!-- input -->
<span /> [link](link)
<!-- output -->
<p><span /> <a href="link">link</a></p>
component tags (unknown tags)
Won't terminate the line and won't be wrapped with <p>
:
<!-- input -->
<Counter /> [link](link)
<!-- output -->
<Counter /> <a href="link">link</a>
from unplugin-vue-markdown.
That looks pretty good 👍🏻
I also like the distinct differentiation between inline, block and component tags.
from unplugin-vue-markdown.
Related Issues (20)
- Parse markdown inside HTML HOT 5
- Is there a way to escape parsing? HOT 2
- feat: improve markdown component name HOT 3
- Double code blocks? HOT 1
- Export typings correctly in package.json
- What is the difference between vite-plugin-vue-markdown and vite-plugin-md? Is vite-plugin-md no longer maintained?
- Accessing frontmatter from outside HOT 2
- 可以支持动态markdown 吗 HOT 1
- How to use as just a component and render a markdown string? HOT 1
- Vite example didn't work - 2 bugs : Element is missing end tag and Unknown word
- Using `<style>` in a Markdown file results in Vite error HOT 1
- Error with `headEnabled = true`: `@vueuse/head` missing
- [For SSR] Failed to resolve components from katex tag names such as ('mo', 'mi', 'msqrt') and resulted a Hydration mismatch HOT 1
- 不支持Vitepress中的Unescape in Code Blocks功能 HOT 1
- [Discussion/Question] Can I pass props into my Markdown components and have them rendered within the Markdown component? HOT 1
- Automatically convert internal links to router links. HOT 1
- Any Render fails when upgrade from 0.25.2 to 0.26.0 HOT 2
- Any Render fails when upgrade from 0.25.2 to 0.26.0 - with demo repo
- Unable to build project after adding this package
- [Bug report] rspack config error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unplugin-vue-markdown.