Brilliant!
In fact opening the text file from Pythonista share didn't work and gave some type mismatch error.
The good news is that sharing from IAwriter directly worked perfectly and produced a markdown to html conversion perfectly!
Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Brilliant!
In fact opening the text file from Pythonista share didn't work and gave some type mismatch error.
The good news is that sharing from IAwriter directly worked perfectly and produced a markdown to html conversion perfectly!
If i open iAWriter and the file i want to share, then the "share" button, followed by "run Pythonista script" and "import file", the result is that the text file is saved into the script folder.
Not exactly what i was looking for, but from there i could probably manipulate the file and convert it to HTML in accordance with my template.
I was hoping to use the "preview markdown" example and extend that script. But as mentioned before, it only retrieves the path rather that the content.
@cvp Thanks, i think that sharing it as input in a script may be the way to go!
After trying to share the file to "Preview Markdown.py", I found that instead of the text, the path of the file is returned by appex.get_text()....
Somewhere the contents gets mixed up, probably in IAwriter...
This awesome piece of code leads to the famous 404...
https://github.com/lukaskollmer/pythonista-scripts/blob/master/x-callback-url/x_callback_url.py
Someone stil has it available?
I'm trying to load a file from IAwriter to process it in phytonista...
Excellent! That seems to do the trick.
So many batteries included that I didn't see Python-Markdown was already included!
Thanks a lot!
(adding own extensions will be a bit more tricky I guess - anyway this is too advanced for me at the moment)
Hi All,
I'm trying to use python-markdown with only limited success. The code below runs fine and produces a html string
import markdown
import inspect
import os
my_text_string = """This is a textstring
spanning multiple lines
## with h2 title
A list
* one [^footnote]
* two
* three
A definition
: with description
[^footnote] this is the content of the note
"""
# pad = os.path.dirname(inspect.getfile(md.core))
# print(pad)
md = markdown.Markdown()
html = md.convert(my_text_string)
print(html)
However as soon as I like to use the standard markdown.extensions.extra, I get an error message: "no module named 'fenced_code' "
This is the first extension listed in the extensions list that is part of the module "extra.py".
With following trace-back:
Traceback (most recent call last):
File "/private/var/mobile/Containers/Shared/AppGroup/../Pythonista3/Documents/pythonista/markdownPlayGround.py", line 27, in <module>
md = markdown.Markdown(extensions=['markdown.extensions.extra'])
File "/private/var/mobile/Containers/Shared/AppGroup/../Pythonista3/Documents/site-packages-3/markdown/core.py", line 97, in __init__
configs=kwargs.get('extension_configs', {}))
File "/private/var/mobile/Containers/Shared/AppGroup/../Pythonista3/Documents/site-packages-3/markdown/core.py", line 125, in registerExtensions
ext._extendMarkdown(self)
File "/private/var/mobile/Containers/Shared/AppGroup/../Pythonista3/Documents/site-packages-3/markdown/extensions/__init__.py", line 77, in _extendMarkdown
self.extendMarkdown(md)
File "/private/var/mobile/Containers/Shared/AppGroup/../Pythonista3/Documents/site-packages-3/markdown/extensions/extra.py", line 54, in extendMarkdown
md.registerExtensions(extensions, self.config)
File "/private/var/mobile/Containers/Shared/AppGroup/../Pythonista3/Documents/site-packages-3/markdown/core.py", line 123, in registerExtensions
ext = self.build_extension(ext, configs.get(ext, {}))
File "/private/var/mobile/Containers/Shared/AppGroup/../Pythonista3/Documents/site-packages-3/markdown/core.py", line 163, in build_extension
module = importlib.import_module(ext_name)
File "/var/containers/Bundle/Application/../Pythonista3.app/Frameworks/Py3Kit.framework/pylib/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'fenced_code'
I have the feeling that this has something to do with the "path" of the module not being passed properly to init.py, but have no clue how to fix this
As you can see markdown sits in site-packages-3 and the "extension" subdirectory is found by the markdown "register extensions" method. So markdown itself seems to work as it should, but then the deeper calls into python(ista) seem to loose track of where to look...