swcarpentry/lesson-template — pull request #44 by r-gaia-cs (2014-12-05 21:44:00+00:00)
Title: Add id to glossary entry

After run

~~~
$ make -C pages preview
~~~

the content of `pages/reference.md` is translate into

~~~

...commands and examples...

Glossary

Key Word 1

Definition of first term

Key Word 2

Definition of second term

~~~

And there a link in `pages/01-one.md` to `reference.html#key-word-1` (or similar) will not work. This pull request try to address this issue.

## Expected Translation

~~~

...commands and examples...

Glossary

Key Word 1

Definition of first term

Key Word 2

Definition of second term

~~~

or

~~~

...commands and examples...

Glossary

Key Word 1

Definition of first term

Key Word 2

Definition of second term

~~~

## Implementation Design

For

~~~
key
: definition
~~~

Pandoc's AST is

~~~
[{"unMeta":{}},[{"t":"DefinitionList","c":[[[{"t":"Str","c":"key"}],[[{"t":"Plain","c":[{"t":"Str","c":"definition"}]}]]]]}]]
~~~

and for

~~~
bar
~~~

is

~~~
[{"unMeta":{}},[{"t":"Para","c":[{"t":"Span","c":[["foo",[],[]],[{"t":"Str","c":"bar"}]]}]}]]
~~~

So we want to have

~~~
[{"unMeta":{}},[{"t":"DefinitionList","c":[[[{"t":"Span","c":[["key",[],[]],[{"t":"Str","c":"key"}]]}],[[{"t":"Plain","c":[{"t":"Str","c":"definition"}]}]]]]}]]
~~~

that will be translate into

~~~

bar

definition

~~~

## How to test

~~~
$ pandoc -t json pages/reference.md|tools/id4glossary.py| pandoc -f json -t html

...commands and examples...

Glossary

Key Word 1

Definition of first term

Key Word 2

Definition of second term

~~~

## TODO

- [ ] Merge `tools/id4glossary.py` and `tools/blockquote2div.py` into `lesson_filter.py` or something similar.
- [ ] Update `pages/Makefile` based on the merge of `tools/id4glossary.py` and `tools/blockquote2div.py`.