Skip to content

Commit

Permalink
Improve hljs colors, improve code rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
ryyppy committed Oct 8, 2019
1 parent 88a6471 commit f32a6d1
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion common/Mdx.re
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Components = {
.
"className": option(string),
"metastring": option(string),
"children": array(ReasonReact.reactElement),
"children": ReasonReact.reactElement,
}),
[@bs.optional]
pre: React.component(props),
Expand Down
15 changes: 9 additions & 6 deletions components/Text.bs.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ function Text$Md$Code(Props) {
} else {
lang = "re";
}
var baseClass = "font-mono block leading-tight";
var codeElement;
if (metastring !== undefined) {
var metaSplits = Belt_List.fromArray(metastring.split(" "));
Expand All @@ -175,15 +174,19 @@ function Text$Md$Code(Props) {
Belt_List.has(metaSplits, "sig", Caml_obj.caml_equal) ? React.createElement(CodeSignature.make, {
code: children,
lang: lang
}) : React.createElement("code", undefined, Util.ReactStuff.ate(children))
}) : React.createElement(CodeExample.make, {
code: children,
lang: lang
})
);
} else {
codeElement = React.createElement("code", {
className: baseClass
}, Util.ReactStuff.ate(children));
codeElement = React.createElement(CodeExample.make, {
code: children,
lang: lang
});
}
return React.createElement("div", {
className: baseClass
className: "font-mono block leading-tight"
}, codeElement);
}

Expand Down
9 changes: 5 additions & 4 deletions components/Text.re
Original file line number Diff line number Diff line change
Expand Up @@ -141,20 +141,21 @@ module Md = {
}
};

let code = Unsafe.elementAsString(children);
let baseClass = "font-mono block leading-tight";
let codeElement =
switch (metastring) {
| None => <code className=baseClass> children->ate </code>
| None => <CodeExample code lang />
| Some(metastring) =>
let metaSplits =
Js.String.split(" ", metastring)->Belt.List.fromArray;

if (Belt.List.has(metaSplits, "example", (==))) {
<CodeExample code={children->Obj.magic} lang />;
<CodeExample code lang />;
} else if (Belt.List.has(metaSplits, "sig", (==))) {
<CodeSignature code={children->Obj.magic} lang />;
<CodeSignature code lang />;
} else {
<code> children->ate </code>;
<CodeExample code lang />;
};
};

Expand Down
6 changes: 5 additions & 1 deletion styles/_hljs.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ Docco style used in http://jashkenas.github.com/docco/ converted by Simon Madine
font-style: italic;
}

.hljs-operator, .hljs-literal {
@apply text-primary
}

.hljs-comment {
@apply text-dark-green;
}
Expand Down Expand Up @@ -55,7 +59,7 @@ Docco style used in http://jashkenas.github.com/docco/ converted by Simon Madine
.hljs-tag,
.hljs-name,
.hljs-attribute {
color: #000080;
@apply text-info-blue;
font-weight: normal;
}

Expand Down

0 comments on commit f32a6d1

Please sign in to comment.