-
-
Notifications
You must be signed in to change notification settings - Fork 144
Markdown dedent, and remove containerProps #569
Conversation
probably OK as is, but just in case...
@@ -11,6 +11,11 @@ import './css/highlight.css'; | |||
* [react-markdown](https://rexxars.github.io/react-markdown/) under the hood. | |||
*/ | |||
class DashMarkdown extends Component { | |||
constructor(props) { | |||
super(props); | |||
this.highlightCode = this.highlightCode.bind(this); |
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.
apparently not needed given our current usage, but makes me nervous to have it there unbound...
pre + | ||
' b\r' + | ||
pre + | ||
'c\r\n' + |
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.
Prettier certainly did not improve clarity here... and its indentation choice is peculiar for this case. Oh well...
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.
cannot partially disable just for this chunk?
const text = ' a\n b'; | ||
const mdDedented = render(<Markdown children={text} />); | ||
expect(mdDedented.find('code').length).toEqual(0); | ||
expect(mdDedented.find('p').length).toEqual(1); |
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.
dedented: makes everything into a <p>
element.
|
||
const mdRaw = render(<Markdown children={text} dedent={false} />); | ||
expect(mdRaw.find('code').length).toEqual(1); | ||
expect(mdRaw.find('p').length).toEqual(0); |
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.
dedent turned off: the leading spaced mean it gets turned into a code block.
Hmm, the percy diffs, now that they're back, may point to a problem, inline |
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.
RegEx looks good to me. I'll double-check by using this in the docs (replacing SyntaxHighlighter
) to see if there are any regressions.
@@ -4,6 +4,21 @@ This project adheres to [Semantic Versioning](http://semver.org/). | |||
|
|||
## [Unreleased] | |||
### Added | |||
- `Markdown` components support code highlighting - no need to switch to `SyntaxHighlighter`, which has been removed. Use triple backticks, with the opening backticks followed by the language name or abbreviation. [#562](https://github.com/plotly/dash-core-components/pull/562) Supported languages: |
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.
Maybe add that Markdown
will attempt to auto-detect the language (via highlight.js
) without specifying the language name
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.
Also maybe mention the theme
prop, but this could be in the docs for dcc.Markdown
as well/instead
# for _ in self.driver.find_element_by_css_selector( | ||
# '#date-picker-range-output').text.split(' - ')])), | ||
# date_tokens, | ||
# "date should match the callback ou |
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.
🙈 👍
const commonLen = commonPrefix ? commonPrefix.length : 0; | ||
return lines | ||
.map(line => { | ||
return line.match(/\S/) ? line.substr(commonLen) : ''; |
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.
💃
Cool, this should make our doc-writing lives easier 🎊
Changelog additions aren't blocking for me
Closes #567
Breaking change for Dash 1.0
Added a
dedent
prop to theMarkdown
component, set totrue
by default. Behavior is intended to matchtextwrap.dedent
- in particular:Also:
containerProps
prop - based on the refactor @wbrgss did in Native syntax highlighting in dcc.Markdown #562 it appears to be useless, as we have the necessaryid
,className
, andstyle
on the container already.react-markdown
component. All props are already used explicitly, this seems like it can only cause problems, it's probably a relic of some older usage.