todo's as dokuwiki's plugin
parent
0e3f7aaa40
commit
17625d6f1d
20
README.md
20
README.md
|
@ -66,6 +66,26 @@ You'll have to come up with your own shortcodes for those.
|
|||
See wp.html in the layouts directory. You could customize interwiki links from dokuwiki: `[[custom>somelink]]` would refer to some custom wiki.
|
||||
Simply add custom.html and link to the website of your choice. Use Hugo's `{{ index .Params 0 }}` to get the link content.
|
||||
|
||||
### TODO's
|
||||
|
||||
There's a dokuwiki plugin which enables things like:
|
||||
|
||||
```html
|
||||
<todo>a todo list</todo>
|
||||
<todo #>done</todo>
|
||||
<todo #>also checked off</todo>
|
||||
```
|
||||
|
||||
Hugo supports this using this MD syntax:
|
||||
|
||||
```
|
||||
- [ ] a todo list
|
||||
- [x] done
|
||||
- [x] also checked off
|
||||
```
|
||||
|
||||
I like lists. So this is naturally supported.
|
||||
|
||||
### I want to create my own syntax conversion!
|
||||
|
||||
No problem, the project was made with extensibility in mind.
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
from src.markdown_converter import MarkdownConverter
|
||||
from re import compile
|
||||
|
||||
@MarkdownConverter.Register
|
||||
class MarkdownTodo():
|
||||
pattern = compile('(<todo(\s#)?>)(.*?)(</todo>)')
|
||||
todo = '- [ ] '
|
||||
done = '- [x] '
|
||||
|
||||
def convert(self, text):
|
||||
result = text
|
||||
for match in MarkdownTodo.pattern.findall(text):
|
||||
prefix = MarkdownTodo.todo if match[1] is '' else MarkdownTodo.done
|
||||
result = result.replace(match[0] + match[2] + match[3], prefix + match[2])
|
||||
return result
|
|
@ -0,0 +1,31 @@
|
|||
from unittest import TestCase
|
||||
|
||||
from src.markdown.todo import MarkdownTodo
|
||||
|
||||
|
||||
class TestMarkdownTodo(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.converter = MarkdownTodo()
|
||||
|
||||
def test_converts_todos_with_marked_as_done(self):
|
||||
src = '''
|
||||
<todo>item 1</todo>
|
||||
<todo #>item 2</todo>
|
||||
'''
|
||||
expected = '''
|
||||
- [ ] item 1
|
||||
- [x] item 2
|
||||
'''
|
||||
self.assertEqual(expected, self.converter.convert(src))
|
||||
|
||||
def test_converts_todos(self):
|
||||
src = '''
|
||||
<todo>item 1</todo>
|
||||
<todo>item 2</todo>
|
||||
'''
|
||||
expected = '''
|
||||
- [ ] item 1
|
||||
- [ ] item 2
|
||||
'''
|
||||
self.assertEqual(expected, self.converter.convert(src))
|
Loading…
Reference in New Issue