-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
add attributes to fence blocks #2394
Conversation
browser/lib/markdown-it-fence.js
Outdated
alt: ['paragraph', 'reference', 'blockquote', 'list'] | ||
}) | ||
|
||
for (let name in renderers) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use const
instead of let
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZeroX-DG thanks! I did learn something today The for-of loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, amazing right? I also discorvered the for-of
loop a few months ago 😄 I realized that I've been in stone age for years 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did know the for-of
loop but I didn't know I could use const
for the iterator. (Since the loop do change the value/address of the variable)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZeroX-DG I've pushed the fix |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daiyam Please change your code to my request. Also, can you change the code in MermaidRender.js
in the catch block in render
function? There's a console.error
command there and it keep throwing error while I typing the graph and we don't need that.
browser/components/markdown.styl
Outdated
&>span.filename | ||
width 100% | ||
border-radius: 5px 0px 0px 0px | ||
margin -8px 100% 8px -8px |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ZeroX-DG I removed the errors for every diagram (chart, flowchart, mermaid and sequence).
I've also fixed a bug with the line number...
But I can't replicated the visual bug you are getting...
Here what I get:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You preview font size is too small, you can set it to 24
and you will see the problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daiyam Can you fix the conflict ? |
@ZeroX-DG it's done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@daiyam I'm sorry for being late response. Could you fix the conflict? |
@Rokt33r all done |
Awesome! |
I've tried the recently released v0.11.10 and also cloned the repo and built the latest master branch, and in both cases I am noticing that mermaid gantt charts seem to be scaling in such that they are rendered at a higher resolution then shrunk to fit my window, or they are too tall.
Here is where export const draw = function (text, id) {
parser.yy.clear()
parser.parse(text)
const elem = document.getElementById(id)
w = elem.parentElement.offsetWidth
if (typeof w === 'undefined') {
w = 1200
}
if (typeof conf.useWidth !== 'undefined') {
w = conf.useWidth
} I've been playing around with it by hardcoding // line 29
mermaidAPI.initialize({
theme: isDarkTheme ? 'dark' : 'default',
themeCSS: isDarkTheme ? darkThemeStyling : '',
gantt: { "useWidth": 800}
// useMaxWidth: false // <-- I don't think this maps to a valid mermaid config option;
// should be `sequence: {useMaxWidth: false},`
// https://github.com/knsv/mermaid/blob/master/src/mermaidAPI.js#L156
}) If others want to set a minimum width, maybe the same result could be obtained more cleanly by configuring If you want to experiment with this default themeconfig.gantt.useWidth:"600"for posterity - this is what the current build (w/o the fixes made earlier in this PR) looks like |
@100ideas the |
This change adds attributes to fence blocks like:
mermaid(50h):Graph 1
Its format is:
language(attributes):fileName:firstLineNumber
.The formats for an attribute are:
name="value"
orname='value'
orname=value
orname
.The attribute
<number>h
is transformed asheight=<number>
For example:
javacript:test.js:5
mermaid
mermaid(50h)
mermaid(height=50):Graph 1
mermaid(height="50"):Graph 1
mermaid(height='50')
chart(yaml 50h):My chart 8
chart
,flowchart
,mermaid
,sequence
will display thefileName
as title.This is a better fix for #2335 than my previous proposed pull request #2340