File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 1
1
def extract_title (markdown ):
2
2
for line in markdown .split ('\n ' ):
3
+ if ".title[" in line :
4
+ start = line .index (".title[" ) + len (".title[" )
5
+ end = line .rindex ("]" , start )
6
+ return line [start :end ]
3
7
if '#' in line :
4
8
index_first_non_whitespace = len (line ) - len (line .lstrip ())
5
9
index_first_hash = line .index ('#' )
@@ -28,5 +32,23 @@ def test_extract_title():
28
32
Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
29
33
Code examples: [OSI](http://opensource.org)-approved [MIT license](http://opensource.org/licenses/mit-license.html).
30
34
35
+ ---'''
36
+ markdown_alt = '''name: inverse
37
+ layout: true
38
+ class: center, middle, inverse
39
+
40
+ ---
41
+
42
+ .title[Talking to [C/C++/Fortran] via CFFI]
43
+
44
+ .author[Radovan Bast]
45
+
46
+ High Performance Computing Group,
47
+ UiT The Arctic University of Norway
48
+
49
+ Licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/).
50
+ Code examples: [OSI](http://opensource.org)-approved [MIT license](http://opensource.org/licenses/mit-license.html).
51
+
31
52
---'''
32
53
assert extract_title (markdown ) == 'Talking to C/C++/Fortran via CFFI'
54
+ assert extract_title (markdown_alt ) == 'Talking to [C/C++/Fortran] via CFFI'
You can’t perform that action at this time.
0 commit comments