Skip to content

Commit

Permalink
Added initial support for hyperlinks.
Browse files Browse the repository at this point in the history
  • Loading branch information
rbejar committed Oct 23, 2023
1 parent d1cc1d9 commit 5125ffd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,15 @@ slide in your presentation, in case you want to make changes in the future, and
single image visible.

## TODO
This is important (to me):
These are important (to me):
- [ ] Text boxes have to be processed. This is especially important for slides with code snippets.
- [ ] Hyperlinks have to be processed.
- [X] Hyperlinks have to be processed.

These are not:
These are not so important:
- [ ] Slides with "big text" could be processed better (perhaps by using a bigger font, or using the text as the title).
- [ ] Some redundancy might be eliminated in the resulting markdown file with a smarter parsing.
- [ ] Tables could be processed (but this might prove too much work for a very occasional use).
- [ ] Hyperlinks wich happen to be emphasized (bold etc.) should be processed too.
- [ ] ...


Expand Down
Binary file modified examples/simple.odp
Binary file not shown.
44 changes: 28 additions & 16 deletions odpmkd/odpmkd.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,20 @@ def handleTextNode(self, node):
if n.nodeName == 'text:span':
if len(n.childNodes) > 0:
t = self.getTextFromNode(n.childNodes[0])
if has_attribute_with_value(n, 'text:style-name', 'T1'):
t = '*' + t + '*'
elif has_attribute_with_value(n, 'text:style-name', 'T2'):
t = '**' + t + '**'
elif has_attribute_with_value(n, 'text:style-name', 'T3'):
t = '<u>' + t + '</u>'
else: # ignore other styles
pass
if t is not None:
if has_attribute_with_value(n, 'text:style-name', 'T1'):
t = '*' + t + '*'
elif has_attribute_with_value(n, 'text:style-name', 'T2'):
t = '**' + t + '**'
elif has_attribute_with_value(n, 'text:style-name', 'T3'):
t = '<u>' + t + '</u>'
else: # ignore other styles
pass
elif n.nodeName == 'text:a': # hyperlinks
if len(n.childNodes) > 0:
t = self.getTextFromNode(n.childNodes[0])
if t is not None:
t = '[' + t + '](' + n.attributes['xlink:href'].value + ')'
else:
t = self.getTextFromNode(n)

Expand Down Expand Up @@ -193,16 +199,22 @@ def _handleTitleRec(node):
if node.nodeName == 'text:span':
if len(node.childNodes) > 0:
t = self.getTextFromNode(node.childNodes[0])
if has_attribute_with_value(node, 'text:style-name', 'T1'):
t = '*' + t + '*'
elif has_attribute_with_value(node, 'text:style-name', 'T2'):
t = '**' + t + '**'
elif has_attribute_with_value(node, 'text:style-name', 'T3'):
t = '<u>' + t + '</u>'
else: # ignore other styles
pass
if t is not None:
if has_attribute_with_value(node, 'text:style-name', 'T1'):
t = '*' + t + '*'
elif has_attribute_with_value(node, 'text:style-name', 'T2'):
t = '**' + t + '**'
elif has_attribute_with_value(node, 'text:style-name', 'T3'):
t = '<u>' + t + '</u>'
else: # ignore other styles
pass
self.currentSlide.title += t
elif node.nodeName == 'text:a': # hyperlinks
if len(node.childNodes) > 0:
t = self.getTextFromNode(node.childNodes[0])
if t is not None:
t = '[' + t + '](' + node.attributes['xlink:href'].value + ')'
self.currentSlide.title += t
else:
t = self.getTextFromNode(node)
if t is None:
Expand Down

0 comments on commit 5125ffd

Please sign in to comment.