Skip to content

Commit bb51eed

Browse files
committed
Merge branch 'develop'
2 parents 7214cc4 + f026b76 commit bb51eed

30 files changed

+408
-210
lines changed

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ For Windows, the path (usually?) is
2828
\Users\YourUser\AppData\Roaming\TeXmacs\plugins
2929
```
3030

31-
You can activate a menu with Tools -> Markdown plugin.
31+
You can activate a menu with `Tools -> Markdown plugin`.
3232

3333
## Hugo support
3434

@@ -37,8 +37,8 @@ converted from TeXmacs, including setting frontmatter values and extensions
3737
like footnotes and ~~striked through text~~.
3838

3939
Setting values for the frontmatter is suported via a dedicated macro defined
40-
in `hugo.ts`. To use it first insert the Markdown -> Hugo package in Document
41-
-> Style -> Add package or using plus sign in the focus bar.
40+
in `hugo.ts`. To use it first insert the `Markdown -> Hugo` package in
41+
`Document -> Style -> Add package` or using the plus sign in the focus bar.
4242

4343
Now you can type `\hugo-front` and input any number of key|value pairs as
4444
arguments, one argument each. That is: type `\hugo-front`, then use structured
@@ -49,18 +49,27 @@ dates (insert with `\date`) are supported as values. To enter a list, input
4949

5050
### Supported shortcodes
5151

52-
* Figures are converted to `{{< figure … >}}`
53-
* For arbitrary shortcodes, use `\hugo-short`.
54-
* Citations are automatically detected and converted to `{{< cite ref >}}`,
55-
and all of them are gathered in the frontmatter as well, for indization by
56-
Hugo's taxonomy system.
57-
* Probably more…
52+
Some of the texmacs markdown requires custom shortcodes and layouts. You can
53+
find them in `extensions/hugo`. Just copy the partials and shortcodes to your
54+
Hugo project.
55+
56+
* Figures are converted to `{{< tmfigure … >}}`. This is a simplified version
57+
of Hugo's `{{<figure>}}`, which can have `.Inner` content. This is required
58+
e.g. to have citations in captions or arbitrary markup.
59+
* To introduce any shortcode in a TeXmacs document, you can use the macro
60+
`\hugo-short`.
61+
* Citations are automatically detected and converted to
62+
`{{< cite ref1 ref2 ... >}}`, and all of them are gathered in the frontmatter
63+
as well, for indization by Hugo's taxonomy system. The presentation of the
64+
label itself is done using CSS. Include the partial `ref_labels.html.html`
65+
in the document `<head>` for that.
66+
* Bibliography is rendered with the `references.html.html` template.
5867

5968
# Known issues
6069

6170
* The converter can break with malformed or unexpected input, like markup
62-
inside tags whose values should be strings (although many cases are
63-
“handled”)
71+
inside tags whose values should be strings, although some cases are (a bit
72+
sloppily) handled.
6473
* Error reporting is rather lacking. Run TeXmacs in a console to see stack
6574
traces and such in case you are running into problems.
6675
* No tables (yet)!

doc/markdown.en.tm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
\\Users\\YourUser\\AppData\\Roaming\\TeXmacs\\plugins
3838
</shell-code>
3939

40-
You can activate a menu with <submenu|Tools|Markdown plugin>.
40+
You can activate a menu with <menu|Tools|Markdown plugin>.
4141

4242
<subsection|Hugo support>
4343

@@ -46,9 +46,9 @@
4646
extensions like footnotes and <strike-through|striked through text>.
4747

4848
Setting values for the frontmatter is suported via a dedicated macro
49-
defined in <code*|hugo.ts>. To use it first insert the
50-
<submenu|Markdown|Hugo> package in <subsubmenu|Document|Style|Add package>
51-
or using plus sign in the focus bar.
49+
defined in <code*|hugo.ts>. To use it first insert the <menu|Markdown|Hugo>
50+
package in <menu|Document|Style|Add package> or using the plus sign in the
51+
focus bar.
5252

5353
Now you can type <verbatim|\\hugo-front> and input any number of key\|value
5454
pairs as arguments, one argument each. That is: type
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{{ $key := index . "key" }}
2+
{{ $page := index . "page" }}
3+
{{ $linkOthers := default true (index . "linkOthers") }}
4+
{{ $bib := site.Data.bibliography.references }}
5+
{{ with $entries := where $bib "id" $key }}
6+
{{ $entry := index $entries 0 }}
7+
{{ $year := (index $entry.issued 0).year }}
8+
<span class="citation-title">{{ $entry.title }}</span>,
9+
<span class="citation-authors">
10+
{{ range $i, $author := $entry.author }}
11+
{{ printf "%s %s" $author.given $author.family }}
12+
{{- if lt $i (sub (len $entry.author) 1)}}, {{end}}
13+
{{- end -}}.
14+
</span>
15+
{{ with index $entry "container-title" }}
16+
<span class="citation-publication">{{.}}</span>
17+
{{ end }}
18+
<span class="citation-date">({{ $year }})</span>
19+
{{ with $entry.URL }}
20+
<a class="citation-link" href="{{.}}">
21+
Publication <i class="fa fa-external-link-alt citation-url"></i>
22+
</a>
23+
{{ end }}
24+
{{ with $entry.note }}
25+
{{ range split . "\n" }}
26+
{{ if hasPrefix . "code:" }}
27+
<a class="citation-link" {{ printf "href=%q" (trim (substr . 6) " ") | safeHTMLAttr }}>
28+
Code <i class="fa fa-external-link-alt citation-url"></i>
29+
</a>
30+
{{ else if hasPrefix . "video:" }}
31+
<a class="citation-link" {{ printf "href=%q" (trim (substr . 6) " ") | safeHTMLAttr }}>
32+
Video <i class="fa fa-external-link-alt citation-url"></i>
33+
</a>
34+
{{ end }}
35+
{{ end }}
36+
{{ end }}
37+
{{ with $term := index (site.Taxonomies.refs) $key }}
38+
{{ if $linkOthers }}
39+
{{ with $total := len (where $term.Pages "Page.RelPermalink" "ne" $page.RelPermalink) }}
40+
<a class="d-inline-block pl-4 citation-link" href="{{ $term.Page.RelPermalink }}">
41+
&mdash; {{ $total }} other item {{- cond (gt $total 1) "s" "" }}
42+
in this site reference {{- cond (gt $total 1) "" "s" }} this.
43+
</a>
44+
{{ end }}
45+
{{ end }}
46+
{{ else }}
47+
<div class="alert alert-danger">
48+
Reference "{{$key}}" missing in taxonomy "refs".
49+
</div>
50+
{{ end }}
51+
{{ else }}
52+
<strong>Wrong citekey: {{ $key }}</strong>
53+
{{ end }}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{/*Include this in the document header*/}}
2+
{{ with .Params.refs }}
3+
<style>
4+
{{ range $key := . }}
5+
{{ $parts := split $key "_" }}
6+
{{ $cite := printf "%s%s%s" (substr (index $parts 0 | title) 0 3) (substr (index $parts 2) 2) (upper (substr (index $parts 1) 0 1)) }}
7+
li#refs-{{$key}}::marker {
8+
content: '[{{$cite}}] ';
9+
font-weight: 600;
10+
font-variant: small-caps;
11+
}
12+
13+
a.cite-{{$key}}::before {
14+
content: '{{$cite}}';
15+
}
16+
17+
{{ end }}
18+
</style>
19+
{{ end }}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<section>
2+
{{- if gt (.Page.Scratch.Get "citations" | uniq | sort) (.Page.Params.refs | uniq | sort) -}}
3+
<div class="alert alert-danger">
4+
There are citations in the text which are not present in the
5+
<code>refs</code> section of the frontmatter.
6+
<pre>{{ .Page.Scratch.Get "citations" | uniq | sort }}</pre>
7+
<pre>{{ .Page.Params.refs | uniq | sort }}</pre>
8+
</div>
9+
{{- end -}}
10+
{{ if .Page.Params.refs }}
11+
<h1>References</h1>
12+
<ul class="references">
13+
{{ range $index, $key := default slice .Page.Params.refs }}
14+
{{/* We use CSS in ref_labels.html.html to decorate the li elements with the citation labels */}}
15+
<li id="refs-{{$key}}">
16+
{{ partial "citation.html.html" (dict "page" $.Page "key" $key) }}
17+
</li>
18+
{{ end }}
19+
</ul>
20+
{{ end }}
21+
</section>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{{- with .Params -}}
2+
{{- $citations := slice -}}
3+
{{- range $key := . -}}
4+
{{- $.Page.Scratch.Add "citations" (slice $key) -}}
5+
{{/* We use CSS in ref_labels.html.html create the classes */}}
6+
{{- $html := printf "<a class=\"cite-%s\" href=\"#refs-%s\"></a>" $key $key -}}
7+
{{- $citations = $citations | append $html -}}
8+
{{- end -}}
9+
<span class="citation">[{{ delimit $citations ", " | safeHTML }}]</span>
10+
{{- end -}}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{{ partial "references.html.html" . }}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{{/* Adapted from Hugo's figure shortcode. https://gohugo.io/ */}}
2+
<figure{{ with .Get "class" }} class="{{ . }}"{{ end }}>
3+
{{- if .Get "link" -}}
4+
<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>{{- end }}
5+
{{ $src := .Get "src"}}
6+
{{- with .Page.Resources.GetMatch $src }}
7+
{{- $src = .RelPermalink }}
8+
{{- end }}
9+
<img src="{{$src | safeURL}}"
10+
{{- if or (.Get "alt") (.Get "caption") }}
11+
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify | plainify }}{{ end }}"
12+
{{- end -}}
13+
{{- with .Get "width" }} width="{{ . }}"{{ end -}}
14+
{{- with .Get "height" }} height="{{ . }}"{{ end -}}
15+
/>
16+
{{- if .Get "link" }}</a>{{ end -}}
17+
{{- if or (.Get "title") (.Get "caption") (.Get "attr") .Inner -}}
18+
<figcaption>
19+
{{ with (.Get "title") -}}
20+
<h4>{{ . }}</h4>
21+
{{- end -}}
22+
{{- with .Inner -}}
23+
<p>
24+
{{ . }}
25+
</p>
26+
{{- end -}}
27+
</figcaption>
28+
{{- end }}
29+
</figure>

packages/aai-tfl.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)