Coder Social home page Coder Social logo

ohbarye / markdown-server Goto Github PK

View Code? Open in Web Editor NEW
42.0 4.0 19.0 35 KB

Simple markdown server written in Python. It converts your markdown file to HTML and returns a response as text/html.

Home Page: https://pypi.python.org/pypi/markdown-server

License: MIT License

Python 100.00%
markdown python

markdown-server's Introduction

Markdown Server

Markdown-server is a simple web application. It converts markdown file to HTML and response by text/html.

How to use

Runtime Environment

Python:3.7
pip:19.1.1

Library Dependencies

See requirements.txt.

Just try

Start server

You don't need any special preparation to try to start server. Just execute below commands.

$ git clone https://github.com/ohbarye/markdown-server
$ cd markdown-server
$ virtualenv .venv
$ source .venv/bin/activate
(.venv)$ pip install -r requirements.txt
(.venv)$ markdownserver
    Bottle v0.12.8 server starting up (using WSGIRefServer())...
    Listening on http://localhost:8009/

Or, you can install from PyPi.

(.venv)$ pip install markdown-server
(.venv)$ markdownserver
    Bottle v0.12.8 server starting up (using WSGIRefServer())...
    Listening on http://localhost:8009/

If server start up successfully, browse below URL and check the converted result.

$ open http://localhost:8009/sample.md

Only Conversion

Additionally, You can use the conversion function alone.

(.venv)$ convert source_md_file target_html_file

Do as you like

  • Markdown server purvey http://host/[file_name] URL. This corresponds to resources/markdown/[file_name].You can put any markdown file here.

  • Converted file will be placed to resources/html directory. Generated html file includes CSS so it's ease to distribute.

  • Environment variables like host name or port number are set in env.py. Edit arbitrarily.

    ms_port        = '8009'
    ms_host        = 'localhost'
    
  • The default markdown engine is Github flavored Markdown. If you want to use another style, add CSS and edit env.py.

    css_name       = 'github.css'
    markdown_type  = 'gfm'
    

markdown-server's People

Contributors

behnejad avatar dependabot[bot] avatar ohbarye avatar victorcabello avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

markdown-server's Issues

Image not found

Hi, does anyone know where I can specified the path to images? I get 404 with images (PNG) files in the same directory as the MD file.

Thanks very much in advance
Albert

Try to run without venv, but failed::

'''
D:\repo-tools\markdown-server>markdownserver
C:\Python27\python.exe: can't open file 'C:\Python27\Scripts\markdownserver': [Errno 2] No such file or directory
'''

ImportError: No module named 'md_to_html'

Just have followed this instruction here: https://pypi.org/project/markdown-server/

But not using python 2.7...(with python2.7 it works fine)
Trying with python 3.5 instead:

user@localhost /tmp $ git clone https://github.com/ohbarye/markdown-server
Cloning into 'markdown-server'...
remote: Enumerating objects: 108, done.
remote: Total 108 (delta 0), reused 0 (delta 0), pack-reused 108
Receiving objects: 100% (108/108), 24.30 KiB | 0 bytes/s, done.
Resolving deltas: 100% (49/49), done.
Checking connectivity... done.
user@localhost /tmp $ cd markdown-server/
user@localhost /tmp/markdown-server $ virtualenv -p /usr/bin/python3.5 .venv
Running virtualenv with interpreter /usr/bin/python3.5
Using base prefix '/usr'
New python executable in /tmp/markdown-server/.venv/bin/python3.5
Also creating executable in /tmp/markdown-server/.venv/bin/python
Installing setuptools, pip, wheel...
done.

user@localhost /tmp/markdown-server $ source .venv/bin/activate
(.venv) user@localhost /tmp/markdown-server $ pip install -r requirements.txt
Collecting bottle==0.12.8 (from -r requirements.txt (line 1))
Collecting linecache2==1.0.0 (from -r requirements.txt (line 2))
  Using cached https://files.pythonhosted.org/packages/c7/a3/c5da2a44c85bfbb6eebcfc1dde24933f8704441b98fdde6528f4831757a6/linecache2-1.0.0-py2.py3-none-any.whl
Collecting Markdown==2.6.2 (from -r requirements.txt (line 3))
  Using cached https://files.pythonhosted.org/packages/59/bf/6bce4d6d91d25eaa58d8e88d8994b2b603ed1b223b25a92f68c3fd0e8fd9/Markdown-2.6.2-py2.py3-none-any.whl
Obtaining markdownserver-master from git+https://github.com/ohbarye/markdown-server@f85a63ba06ca7cb5beb59bd96153d7ba1fa867ae#egg=markdownserver-master (from -r requirements.txt (line 4))
  Cloning https://github.com/ohbarye/markdown-server (to revision f85a63ba06ca7cb5beb59bd96153d7ba1fa867ae) to ./.venv/src/markdownserver-master
  Running command git clone -q https://github.com/ohbarye/markdown-server /tmp/markdown-server/.venv/src/markdownserver-master
  Running command git checkout -q f85a63ba06ca7cb5beb59bd96153d7ba1fa867ae
  WARNING: Generating metadata for package markdownserver-master produced metadata for project name markdownserver. Fix your #egg=markdownserver-master fragments.
Collecting py-gfm==0.1.0 (from -r requirements.txt (line 5))
Collecting Pygments==2.0.2 (from -r requirements.txt (line 6))
  Using cached https://files.pythonhosted.org/packages/87/e3/cadb43a197476ec0adef73292ea7ea188f2b0531188eebc150905d3ed78c/Pygments-2.0.2-py3-none-any.whl
Collecting six==1.9.0 (from -r requirements.txt (line 7))
  Using cached https://files.pythonhosted.org/packages/10/e3/a7f8eea80a9fa8358c1cd89ef489bc03675e69e54ed2982cd6f2a28d8295/six-1.9.0-py2.py3-none-any.whl
Collecting traceback2==1.4.0 (from -r requirements.txt (line 8))
  Using cached https://files.pythonhosted.org/packages/17/0a/6ac05a3723017a967193456a2efa0aa9ac4b51456891af1e2353bb9de21e/traceback2-1.4.0-py2.py3-none-any.whl
Collecting unittest2==1.0.1 (from -r requirements.txt (line 9))
  Using cached https://files.pythonhosted.org/packages/e3/f0/cb7c6303f03509045e1ec167db2b5a01d36bb616d710e895038bdb509fff/unittest2-1.0.1-py2.py3-none-any.whl
Requirement already satisfied: setuptools in ./.venv/lib/python3.5/site-packages (from py-gfm==0.1.0->-r requirements.txt (line 5)) (41.0.1)
Collecting argparse (from unittest2==1.0.1->-r requirements.txt (line 9))
  Using cached https://files.pythonhosted.org/packages/f2/94/3af39d34be01a24a6e65433d19e107099374224905f1e0cc6bbe1fd22a2f/argparse-1.4.0-py2.py3-none-any.whl
Installing collected packages: bottle, linecache2, Markdown, Pygments, traceback2, six, argparse, unittest2, py-gfm, markdownserver
  Running setup.py develop for markdownserver
Successfully installed Markdown-2.6.2 Pygments-2.0.2 argparse-1.4.0 bottle-0.12.8 linecache2-1.0.0 markdownserver py-gfm-0.1.0 six-1.9.0 traceback2-1.4.0 unittest2-1.0.1

(.venv) user@localhost /tmp/markdown-server $ markdownserver
Traceback (most recent call last):
  File "/tmp/markdown-server/.venv/bin/markdownserver", line 11, in <module>
    load_entry_point('markdownserver', 'console_scripts', 'markdownserver')()
  File "/tmp/markdown-server/.venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/tmp/markdown-server/.venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2843, in load_entry_point
    return ep.load()
  File "/tmp/markdown-server/.venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2434, in load
    return self.resolve()
  File "/tmp/markdown-server/.venv/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2440, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/tmp/markdown-server/.venv/src/markdownserver-master/markdownserver/__init__.py", line 2, in <module>
    from md_to_html import MarkdownConverter
ImportError: No module named 'md_to_html'
(.venv) user@localhost /tmp/markdown-server $

Any ideas?
How could we port it to python3.5?

No such file or directory: 'markdownserver/resources/css/github.css'

After a fresh install.

markdown-server==0.1.1
Python 2.7.11

Traceback (most recent call last):
  File "/Users/amitu/.pyenv/versions/home/bin/mdsvr", line 7, in <module>
    from markdownserver import main
  File "/Users/amitu/.pyenv/versions/home/lib/python2.7/site-packages/markdownserver/__init__.py", line 5, in <module>
    converter = MarkdownConverter()
  File "/Users/amitu/.pyenv/versions/home/lib/python2.7/site-packages/markdownserver/markdown_converter.py", line 9, in __init__
    css = codecs.open(css_root + css_name,encoding=ms_encoding,mode='r')
  File "/Users/amitu/.pyenv/versions/home/lib/python2.7/codecs.py", line 896, in open
    file = __builtin__.open(filename, mode, buffering)
IOError: [Errno 2] No such file or directory: 'markdownserver/resources/css/github.css'

Python 3 : ERROR: No matching distribution found for markdownserver-master (unavailable)

Tried downloading code. Using python 3
tried pip3 install -r requirements.txt
and pip install -r requirements.txt
Both gave errors below

Discarding git+https://github.com/ohbarye/markdown-server@f85a63ba06ca7cb5beb59bd96153d7ba1fa867ae#egg=markdownserver-master: Requested markdownserver from git+https://github.com/ohbarye/markdown-server@f85a63ba06ca7cb5beb59bd96153d7ba1fa867ae#egg=markdownserver-master (from -r requirements.txt (line 4)) has inconsistent name: filename has 'markdownserver-master', but metadata has 'markdownserver'

Collecting Markdown==2.6.2
Using cached Markdown-2.6.2-py2.py3-none-any.whl (157 kB)
ERROR: Could not find a version that satisfies the requirement markdownserver-master (unavailable) (from versions: none)
v

Internal Server Error (HTTP 500) when loading images

A markdown like:

![Screenshot](01.png)

produces the following error:

Traceback (most recent call last):
  File "D:\Python27\Scripts\bottle.py", line 862, in _handle
    return route.call(**args)
  File "D:\Python27\Scripts\bottle.py", line 1732, in wrapper
    rv = callback(*a, **ka)
  File "\desktop\markdown-server\src\markdownserver-master\markdownserver\__init__.py", line 10, in gfmize
    html_file_name = converter.convert(resource)
  File "\desktop\markdown-server\src\markdownserver-master\markdownserver\md_to_html.py", line 30, in convert
    code = md.markdown(self.read_md(file_name), extensions=[markdown_type])
  File "\desktop\markdown-server\src\markdownserver-master\markdownserver\md_to_html.py", line 35, in read_md
    return md_file.read()
  File "d:\python27\lib\codecs.py", line 674, in read
    return self.reader.read(size)
  File "d:\python27\lib\codecs.py", line 480, in read
    newchars, decodedbytes = self.decode(data, self.errors)
UnicodeDecodeError: 'utf8' codec can't decode byte 0x89 in position 0: invalid start byte
127.0.0.1 - - [28/Jul/2016 15:46:57] "GET /01.png HTTP/1.1" 500 902977

The image is located in markdownserver/resources/markdown

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.