[gnome-builder] markdown: add css to markdown preview.
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] markdown: add css to markdown preview.
- Date: Thu, 11 Sep 2014 22:55:43 +0000 (UTC)
commit 6ecbe54b47e63778d1604c616200d1015f9a411f
Author: Christian Hergert <christian hergert me>
Date: Thu Sep 11 15:55:28 2014 -0700
markdown: add css to markdown preview.
src/markdown/gb-markdown-preview.c | 11 +-
src/resources/css/markdown.css | 645 +++++++++++++++++++++++++++++
src/resources/gnome-builder.gresource.xml | 1 +
3 files changed, 655 insertions(+), 2 deletions(-)
---
diff --git a/src/markdown/gb-markdown-preview.c b/src/markdown/gb-markdown-preview.c
index 3822fc1..5b39f4e 100644
--- a/src/markdown/gb-markdown-preview.c
+++ b/src/markdown/gb-markdown-preview.c
@@ -65,16 +65,22 @@ static void
gb_markdown_preview_load_html (GbMarkdownPreview *preview,
const gchar *html)
{
+ GBytes *css;
gchar *built_html;
- const gchar *css = "";
+ const guint8 *css_data;
+ css = g_resources_lookup_data ("/org/gnome/builder/css/markdown.css", 0, NULL);
+ css_data = g_bytes_get_data (css, NULL);
+ g_print (">> %s\n", (gchar *)css_data);
built_html = g_strdup_printf ("<html>\n"
" <style>%s</style>\n"
" <body>\n"
+ " <div class=\"markdown-body\">\n"
" %s\n"
+ " </div>\n"
" </body>\n"
"</html>",
- css, html);
+ (gchar *)css_data, html);
/*
* TODO: Load CSS
@@ -83,6 +89,7 @@ gb_markdown_preview_load_html (GbMarkdownPreview *preview,
webkit_web_view_load_html (WEBKIT_WEB_VIEW (preview),
built_html, NULL);
+ g_bytes_unref (css);
g_free (built_html);
}
diff --git a/src/resources/css/markdown.css b/src/resources/css/markdown.css
new file mode 100644
index 0000000..261c701
--- /dev/null
+++ b/src/resources/css/markdown.css
@@ -0,0 +1,645 @@
+/* this file came from
https://raw.githubusercontent.com/sindresorhus/github-markdown-css/gh-pages/github-markdown.css */
+
+.markdown-body {
+ font-family: sans-serif;
+ -ms-text-size-adjust: 100%;
+ -webkit-text-size-adjust: 100%;
+ font: 13px Helvetica, arial, freesans, clean, sans-serif;
+ line-height: 1.4;
+ color: #333333;
+ font-size: 15px;
+ line-height: 1.7;
+ overflow: hidden;
+ word-wrap: break-word;
+}
+
+.markdown-body a {
+ background: transparent;
+}
+
+.markdown-body a:active,
+.markdown-body a:hover {
+ outline: 0;
+}
+
+.markdown-body strong {
+ font-weight: bold;
+}
+
+.markdown-body h1 {
+ font-size: 2em;
+ margin: 0.67em 0;
+}
+
+.markdown-body img {
+ border: 0;
+}
+
+.markdown-body hr {
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+ height: 0;
+}
+
+.markdown-body pre {
+ overflow: auto;
+}
+
+.markdown-body code,
+.markdown-body pre {
+ font-family: monospace, monospace;
+ font-size: 1em;
+}
+
+.markdown-body table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+
+.markdown-body td,
+.markdown-body th {
+ padding: 0;
+}
+
+.markdown-body * {
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+.markdown-body a {
+ color: #4183c4;
+ text-decoration: none;
+}
+
+.markdown-body a:hover {
+ text-decoration: underline;
+}
+
+.markdown-body a:focus,
+.markdown-body a:active {
+ text-decoration: underline;
+}
+
+.markdown-body hr {
+ height: 0;
+ margin: 15px 0;
+ overflow: hidden;
+ background: transparent;
+ border: 0;
+ border-bottom: 1px solid #ddd;
+}
+
+.markdown-body hr:before,
+.markdown-body hr:after {
+ content: " ";
+ display: table;
+}
+
+.markdown-body hr:after {
+ clear: both;
+}
+
+.markdown-body ol ol {
+ list-style-type: lower-roman;
+}
+
+.markdown-body h1,
+.markdown-body h2,
+.markdown-body h3,
+.markdown-body h4,
+.markdown-body h5,
+.markdown-body h6 {
+ margin-top: 15px;
+ margin-bottom: 15px;
+ line-height: 1.1;
+}
+
+.markdown-body h1 {
+ font-size: 30px;
+}
+
+.markdown-body h2 {
+ font-size: 21px;
+}
+
+.markdown-body h3 {
+ font-size: 16px;
+}
+
+.markdown-body h4 {
+ font-size: 14px;
+}
+
+.markdown-body h5 {
+ font-size: 12px;
+}
+
+.markdown-body h6 {
+ font-size: 11px;
+}
+
+.markdown-body blockquote {
+ margin: 0;
+}
+
+.markdown-body ul,
+.markdown-body ol {
+ padding: 0;
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+.markdown-body dd {
+ margin-left: 0;
+}
+
+.markdown-body code,
+.markdown-body pre {
+ font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
+ font-size: 12px;
+}
+
+.markdown-body pre {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+.markdown-body>*:first-child {
+ margin-top: 0 !important;
+}
+
+.markdown-body>*:last-child {
+ margin-bottom: 0 !important;
+}
+
+.markdown-body a.anchor {
+ display: block;
+ padding-right: 6px;
+ padding-left: 30px;
+ margin-left: -30px;
+ cursor: pointer;
+ position: absolute;
+ top: 0;
+ left: 0;
+ bottom: 0;
+}
+
+.markdown-body a.anchor:focus {
+ outline: none;
+}
+
+.markdown-body h1,
+.markdown-body h2,
+.markdown-body h3,
+.markdown-body h4,
+.markdown-body h5,
+.markdown-body h6 {
+ margin: 1em 0 15px;
+ padding: 0;
+ font-weight: bold;
+ line-height: 1.7;
+ cursor: text;
+ position: relative;
+}
+
+.markdown-body h1 {
+ font-size: 2.5em;
+ border-bottom: 1px solid #ddd;
+}
+
+.markdown-body h2 {
+ font-size: 2em;
+ border-bottom: 1px solid #eee;
+}
+
+.markdown-body h3 {
+ font-size: 1.5em;
+}
+
+.markdown-body h4 {
+ font-size: 1.2em;
+}
+
+.markdown-body h5 {
+ font-size: 1em;
+}
+
+.markdown-body h6 {
+ color: #777;
+ font-size: 1em;
+}
+
+.markdown-body p,
+.markdown-body blockquote,
+.markdown-body ul,
+.markdown-body ol,
+.markdown-body dl,
+.markdown-body table,
+.markdown-body pre {
+ margin: 15px 0;
+}
+
+.markdown-body hr {
+ background: transparent
url(data:image/png;base64,iVBORw0KGgoAAAANSUh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zg3MkMyOUY0OCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PqqezsUAAAAfSURBVHjaYmRABcYwBiM2QSA4y4hNEKYDQxAEAAIMAHNGAzhkPOlYAAAAAElFTkSuQmCC)
repeat-x 0 0;
+ border: 0 none;
+ color: #ccc;
+ height: 4px;
+ padding: 0;
+ margin: 15px 0;
+}
+
+.markdown-body ul,
+.markdown-body ol {
+ padding-left: 30px;
+}
+
+.markdown-body ol ol,
+.markdown-body ol ul {
+ margin-top: 0;
+ margin-bottom: 0;
+}
+
+.markdown-body dl {
+ padding: 0;
+}
+
+.markdown-body dl dt {
+ font-size: 14px;
+ font-weight: bold;
+ font-style: italic;
+ padding: 0;
+ margin-top: 15px;
+}
+
+.markdown-body dl dd {
+ margin-bottom: 15px;
+ padding: 0 15px;
+}
+
+.markdown-body blockquote {
+ border-left: 4px solid #DDD;
+ padding: 0 15px;
+ color: #777;
+}
+
+.markdown-body blockquote>:first-child {
+ margin-top: 0px;
+}
+
+.markdown-body blockquote>:last-child {
+ margin-bottom: 0px;
+}
+
+.markdown-body table {
+ width: 100%;
+ overflow: auto;
+ display: block;
+}
+
+.markdown-body table th {
+ font-weight: bold;
+}
+
+.markdown-body table th,
+.markdown-body table td {
+ border: 1px solid #ddd;
+ padding: 6px 13px;
+}
+
+.markdown-body table tr {
+ border-top: 1px solid #ccc;
+ background-color: #fff;
+}
+
+.markdown-body table tr:nth-child(2n) {
+ background-color: #f8f8f8;
+}
+
+.markdown-body img {
+ max-width: 100%;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+
+.markdown-body code {
+ margin: 0;
+ border: 1px solid #ddd;
+ background-color: #f8f8f8;
+ border-radius: 3px;
+ padding: 0;
+}
+
+.markdown-body code:before,
+.markdown-body code:after {
+ content: "\00a0";
+ letter-spacing: -0.2em;
+}
+
+.markdown-body pre>code {
+ margin: 0;
+ padding: 0;
+ white-space: pre;
+ border: none;
+ background: transparent;
+}
+
+.markdown-body .highlight pre,
+.markdown-body pre {
+ background-color: #f8f8f8;
+ border: 1px solid #ddd;
+ font-size: 13px;
+ line-height: 19px;
+ overflow: auto;
+ padding: 6px 10px;
+ border-radius: 3px;
+}
+
+.markdown-body pre {
+ word-wrap: normal;
+}
+
+.markdown-body pre code {
+ margin: 0;
+ padding: 0;
+ background-color: transparent;
+ border: none;
+ word-wrap: normal;
+ max-width: initial;
+ display: inline;
+ overflow: initial;
+ line-height: inherit;
+}
+
+.markdown-body pre code:before,
+.markdown-body pre code:after {
+ content: normal;
+}
+
+.markdown-body .highlight {
+ background: #ffffff;
+}
+
+.markdown-body .highlight .c {
+ color: #999988;
+ font-style: italic;
+}
+
+.markdown-body .highlight .err {
+ color: #a61717;
+ background-color: #e3d2d2;
+}
+
+.markdown-body .highlight .k {
+ font-weight: bold;
+}
+
+.markdown-body .highlight .o {
+ font-weight: bold;
+}
+
+.markdown-body .highlight .cm {
+ color: #999988;
+ font-style: italic;
+}
+
+.markdown-body .highlight .cp {
+ color: #999999;
+ font-weight: bold;
+}
+
+.markdown-body .highlight .c1 {
+ color: #999988;
+ font-style: italic;
+}
+
+.markdown-body .highlight .cs {
+ color: #999999;
+ font-weight: bold;
+ font-style: italic;
+}
+
+.markdown-body .highlight .gd {
+ color: #000000;
+ background-color: #ffdddd;
+}
+
+.markdown-body .highlight .gd .x {
+ color: #000000;
+ background-color: #ffaaaa;
+}
+
+.markdown-body .highlight .ge {
+ font-style: italic;
+}
+
+.markdown-body .highlight .gr {
+ color: #aa0000;
+}
+
+.markdown-body .highlight .gh {
+ color: #999999;
+}
+
+.markdown-body .highlight .gi {
+ color: #000000;
+ background-color: #ddffdd;
+}
+
+.markdown-body .highlight .gi .x {
+ color: #000000;
+ background-color: #aaffaa;
+}
+
+.markdown-body .highlight .go {
+ color: #888888;
+}
+
+.markdown-body .highlight .gp {
+ color: #555555;
+}
+
+.markdown-body .highlight .gs {
+ font-weight: bold;
+}
+
+.markdown-body .highlight .gu {
+ color: #800080;
+ font-weight: bold;
+}
+
+.markdown-body .highlight .gt {
+ color: #aa0000;
+}
+
+.markdown-body .highlight .kc {
+ font-weight: bold;
+}
+
+.markdown-body .highlight .kd {
+ font-weight: bold;
+}
+
+.markdown-body .highlight .kn {
+ font-weight: bold;
+}
+
+.markdown-body .highlight .kp {
+ font-weight: bold;
+}
+
+.markdown-body .highlight .kr {
+ font-weight: bold;
+}
+
+.markdown-body .highlight .kt {
+ color: #445588;
+ font-weight: bold;
+}
+
+.markdown-body .highlight .m {
+ color: #009999;
+}
+
+.markdown-body .highlight .s {
+ color: #dd1144;
+}
+
+.markdown-body .highlight .n {
+ color: #333333;
+}
+
+.markdown-body .highlight .na {
+ color: teal;
+}
+
+.markdown-body .highlight .nb {
+ color: #0086b3;
+}
+
+.markdown-body .highlight .nc {
+ color: #445588;
+ font-weight: bold;
+}
+
+.markdown-body .highlight .no {
+ color: teal;
+}
+
+.markdown-body .highlight .ni {
+ color: purple;
+}
+
+.markdown-body .highlight .ne {
+ color: #990000;
+ font-weight: bold;
+}
+
+.markdown-body .highlight .nf {
+ color: #990000;
+ font-weight: bold;
+}
+
+.markdown-body .highlight .nn {
+ color: #555555;
+}
+
+.markdown-body .highlight .nt {
+ color: navy;
+}
+
+.markdown-body .highlight .nv {
+ color: teal;
+}
+
+.markdown-body .highlight .ow {
+ font-weight: bold;
+}
+
+.markdown-body .highlight .w {
+ color: #bbbbbb;
+}
+
+.markdown-body .highlight .mf {
+ color: #009999;
+}
+
+.markdown-body .highlight .mh {
+ color: #009999;
+}
+
+.markdown-body .highlight .mi {
+ color: #009999;
+}
+
+.markdown-body .highlight .mo {
+ color: #009999;
+}
+
+.markdown-body .highlight .sb {
+ color: #dd1144;
+}
+
+.markdown-body .highlight .sc {
+ color: #dd1144;
+}
+
+.markdown-body .highlight .sd {
+ color: #dd1144;
+}
+
+.markdown-body .highlight .s2 {
+ color: #dd1144;
+}
+
+.markdown-body .highlight .se {
+ color: #dd1144;
+}
+
+.markdown-body .highlight .sh {
+ color: #dd1144;
+}
+
+.markdown-body .highlight .si {
+ color: #dd1144;
+}
+
+.markdown-body .highlight .sx {
+ color: #dd1144;
+}
+
+.markdown-body .highlight .sr {
+ color: #009926;
+}
+
+.markdown-body .highlight .s1 {
+ color: #dd1144;
+}
+
+.markdown-body .highlight .ss {
+ color: #990073;
+}
+
+.markdown-body .highlight .bp {
+ color: #999999;
+}
+
+.markdown-body .highlight .vc {
+ color: teal;
+}
+
+.markdown-body .highlight .vg {
+ color: teal;
+}
+
+.markdown-body .highlight .vi {
+ color: teal;
+}
+
+.markdown-body .highlight .il {
+ color: #009999;
+}
+
+.markdown-body .highlight .gc {
+ color: #999;
+ background-color: #EAF2F5;
+}
diff --git a/src/resources/gnome-builder.gresource.xml b/src/resources/gnome-builder.gresource.xml
index 72a41f7..71cf7e7 100644
--- a/src/resources/gnome-builder.gresource.xml
+++ b/src/resources/gnome-builder.gresource.xml
@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/org/gnome/builder">
<file>css/builder.Adwaita.css</file>
+ <file>css/markdown.css</file>
<file>editor/uncrustify/uncrustify.c.cfg</file>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]