Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up templates #28

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Update CSS
run: script/update-css
- name: Update preview template
run: script/update-preview-template
- name: Create or update pull-request
id: create-pull-request
uses: peter-evans/create-pull-request@v4
with:
title: Update CSS 💅
title: Update preview template 💅
body: https://github.com/sindresorhus/github-markdown-css
commit-message: Update CSS 💅
commit-message: Update preview template 💅
delete-branch: true
labels: automated pull-request
- name: Print pull-request details
Expand Down
9 changes: 4 additions & 5 deletions examples/basic.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ $ maxdown input.md
<!DOCTYPE html>
<html>
<head>
...
<meta charset="utf-8">
<title>Preview</title>
<base href="">
...
</head>
<body class="markdown-body">
<body>
<p>Hello <strong>Markdown</strong>!</p>
</body>
</html>
Expand All @@ -33,7 +32,7 @@ $ maxdown --title "Pizzazz" input.md
<title>Pizzazz</title>
...
</head>
<body class="markdown-body">
<body>
<p>Hello <strong>Markdown</strong>!</p>
</body>
</html>
Expand All @@ -53,7 +52,7 @@ $ maxdown --base "https://github.com/pmeinhardt/maxdown" input.md
<base href="https://github.com/pmeinhardt/maxdown">
...
</head>
<body class="markdown-body">
<body>
<p>Hello <strong>Markdown</strong>!</p>
</body>
</html>
Expand Down
2 changes: 1 addition & 1 deletion examples/read-stdin.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
...
</head>
<body class="markdown-body">
<body>
<p>Hello I/O!</p>
</body>
</html>
Expand Down
2 changes: 1 addition & 1 deletion examples/write-file.out/output.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<head>
...
</head>
<body class="markdown-body">
<body>
<p>Just here for the input.</p>
</body>
</html>
2 changes: 1 addition & 1 deletion plugin/maxdown.vim
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ function! s:convert() abort

let args = [
\ '--dangerous',
\ '--template', shellescape(s:path . '/src/minimal-template.html'),
\ '--title', shellescape(expand('%:t')),
\ '-',
\ ]
Expand All @@ -44,6 +43,7 @@ function! s:invoke(dest, source, bnum) abort
\ '--dangerous',
\ '--base', shellescape(a:source),
\ '--output', shellescape(a:dest),
\ '--template', shellescape(s:path . '/src/preview-template.html'),
\ '-'
\ ]

Expand Down
10 changes: 4 additions & 6 deletions script/update-css → script/get-github-markdown-css
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ BASE="https://raw.githubusercontent.com/sindresorhus/github-markdown-css/main"
CSS="$BASE/github-markdown.css"
LICENSE="$BASE/license"

{
printf '/*\n'
curl --silent --show-error "$LICENSE"
printf '*/\n\n'
curl --silent --show-error "$CSS"
} > src/github.css
printf '/*\n'
curl --silent --show-error "$LICENSE"
printf '*/\n\n'
curl --silent --show-error "$CSS"
16 changes: 16 additions & 0 deletions script/update-preview-template
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

cd "$(dirname "$0")/.."

TEMPLATE="src/preview-template-template.html"
OUTPUT="src/preview-template.html"

CSS="$(script/get-github-markdown-css | sed '2,$s/^/ /' | sed 's/ *$//')"
export CSS

# shellcheck disable=SC2016
envsubst '${CSS}' < "$TEMPLATE" > "$OUTPUT"
9 changes: 1 addition & 8 deletions src/default-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,8 @@
<meta charset="utf-8">
<title>{{ title }}</title>
<base href="{{ base }}">
<style>
.markdown-body {
padding: 2rem;
}

{{ default-css }}
</style>
</head>
<body class="markdown-body">
<body>
{{ content }}
</body>
</html>
Loading
Loading