Skip to content
Permalink
8a4a844378
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
82 lines (61 sloc) 2.24 KB
"""
reMarkable: Convert markdown to docs using Templates
Copyright (C) 2020 Dan Goldsmith (djgoldsmith@googlemail.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
"""
possibly a little overkill, but I may want
to do per section stuff. Saves Refactoring down the line
"""
import remarkable.renderer as renderer
class Section():
"""Class for Sections
At the moment a placeholder for sections. Lets me parse and work
out all the meta data
"""
def __init__(self, text, marks=None):
self.text = text
self.marks = marks
def updateMarks(self, marks):
"""
Update the marks awarded for a section
WARNING: You will need to cast the marks.
"""
self.marks = marks
def asStr(self):
"""
Render the text as a string
Here we will strip out the first and last items if they are
empty. This is a side affect of the parsing process
"""
temp = self.text
if temp[0] == "":
temp = temp[1:]
if temp[-1] == "":
temp = temp[:-1]
return "\n".join(temp)
def markdown(self):
"""
Render the text as from markdown
TODO: Consider this as it may be more applicable to do it in
the rendrer
"""
inText = "\n".join(self.text)
html = renderer.markdowner.convert(inText)
return html
def __str__(self):
"""String representation.
Renders the text as Markdown, and returns it. Makes templates
much cleaner as we don't need to call the markdown()
explicitly
"""
return self.markdown()