diff --git a/lib/renderer.js b/lib/renderer.js
index ecc9139..03e8c8f 100644
--- a/lib/renderer.js
+++ b/lib/renderer.js
@@ -56,9 +56,15 @@ var render = function (text, filePath) {
renderer = new marked.Renderer()
renderer.listitem = function (text, isTask) {
- const listAttributes = isTask ? ' class="task-list-item"' : ''
+ if (isTask) {
+ const textOnly = text.replace(/^/, '').trim()
+ const isChecked = /checked=""/.test(text)
- return `
${text}\n`
+ const checkbox = ``
+ return `${checkbox} ${textOnly}\n`
+ }
+
+ return `${text}\n`
}
}
diff --git a/styles/markdown-preview-default.less b/styles/markdown-preview-default.less
index 25f7ade..eb40b52 100644
--- a/styles/markdown-preview-default.less
+++ b/styles/markdown-preview-default.less
@@ -154,3 +154,40 @@
}
}
+
+// Align task list checkboxes --------------------
+.checkbox-position(@x, @y, @margin: 0) {
+ .markdown-preview:not([data-use-github-style]) {
+ .task-list-item .input-checkbox {
+ position: absolute;
+ transform: translate(~"calc(-50% - @{x})", ~"calc(-50% + @{y})");
+ }
+
+ .task-list-item {
+ margin: @margin 0 !important;
+ }
+ }
+}
+
+
+.checkbox-position(13px, 10px);
+
+.theme-atom-dark-ui, .theme-atom-light-ui {
+ .checkbox-position(13px, 10px, .1em);
+}
+
+.theme-atom-material-ui {
+ .checkbox-position(15px, 9px, .4em);
+}
+
+.theme-nucleus-dark-ui {
+ .checkbox-position(14px, 12px);
+}
+
+.theme-solarized-dark-ui {
+ .checkbox-position(13px, 9px, .1em);
+}
+
+.theme-solarized-light-ui {
+ .checkbox-position(14px, 12px, .1em);
+}
diff --git a/styles/markdown-preview-github.less b/styles/markdown-preview-github.less
index fedb5cb..9d34e4a 100644
--- a/styles/markdown-preview-github.less
+++ b/styles/markdown-preview-github.less
@@ -37,4 +37,16 @@
border-radius: 4px;
overflow: auto;
}
+
+ .task-list-item input[type=checkbox] {
+ margin: 0 .5em .25em -1.6em;
+ vertical-align: middle;
+ height: initial; width: initial;
+
+ -webkit-appearance: checkbox;
+
+ &::before, &:after {
+ display: none;
+ }
+ }
}
diff --git a/styles/markdown-preview.less b/styles/markdown-preview.less
index bff8cec..99ac95e 100644
--- a/styles/markdown-preview.less
+++ b/styles/markdown-preview.less
@@ -19,12 +19,7 @@
user-select: auto;
}
- // move task list checkboxes
- .task-list-item input[type=checkbox] {
- position: absolute;
- margin: .25em 0 0 -1.4em;
- }
-
+ // remove task list bullets
.task-list-item {
list-style-type: none;
}