Skip to content

Commit

Permalink
Markdown: add code block font size parameter (revery-ui#916)
Browse files Browse the repository at this point in the history
  • Loading branch information
zbaylin authored Jun 22, 2020
1 parent 2ee8499 commit f3f2e9b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/UI_Components/Markdown.re
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type style = {
h6: list(Style.textStyleProps),
fontFamily: Family.t,
codeFontFamily: Family.t,
codeBlockFontSize: float,
baseFontSize: float,
codeBlock: list(Style.viewStyleProps),
};
Expand Down Expand Up @@ -405,16 +406,14 @@ and generateCodeBlock =
m("Code block has label : %s", Option.value(label, ~default="(none)"))
);

let fontSize = fontSizeFromKind(`InlineCode, styles);

<View style={styles.codeBlock}>
{switch (label, codeBlock.code) {
| (None, Some(code)) =>
<Text
text=code
fontFamily={styles.codeFontFamily}
monospaced=true
fontSize
fontSize={styles.codeBlockFontSize}
style=Style.[
textWrap(TextWrapping.WrapIgnoreWhitespace),
...{styles.paragraph},
Expand Down Expand Up @@ -448,7 +447,7 @@ and generateCodeBlock =
fontFamily={styles.codeFontFamily}
fontWeight={block.bold ? Weight.Bold : Weight.Normal}
monospaced=true
fontSize
fontSize={styles.codeBlockFontSize}
/>;
},
highlight,
Expand Down Expand Up @@ -482,6 +481,7 @@ let%component make =
~fontFamily=Family.default,
~codeFontFamily=Family.default,
~baseFontSize=14.0,
~codeBlockFontSize=baseFontSize,
~paragraphStyle=Style.emptyTextStyle,
~activeLinkStyle=Style.emptyTextStyle,
~inactiveLinkStyle=Style.emptyTextStyle,
Expand Down Expand Up @@ -517,6 +517,7 @@ let%component make =
fontFamily,
codeFontFamily,
baseFontSize,
codeBlockFontSize,
codeBlock: codeBlockStyle,
},
syntaxHighlighter,
Expand Down
1 change: 1 addition & 0 deletions src/UI_Components/Markdown.rei
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ let make:
~fontFamily: Revery_Font.Family.t=?,
~codeFontFamily: Revery_Font.Family.t=?,
~baseFontSize: float=?,
~codeBlockFontSize: float=?,
~paragraphStyle: list(Revery_UI.Style.textStyleProps)=?,
~activeLinkStyle: list(Revery_UI.Style.textStyleProps)=?,
~inactiveLinkStyle: list(Revery_UI.Style.textStyleProps)=?,
Expand Down

0 comments on commit f3f2e9b

Please sign in to comment.