10 Commits

Author SHA1 Message Date
Masato Ohba bf069d12c3 Merge pull request #16 from ohbarye/gitattributes
Create .gitattributes to override repository language
2021-09-05 11:06:57 +09:00
Masato Ohba 1c4f1d8176 Create .gitattributes to override repository language
https://github.com/github/linguist/blob/master/docs/overrides.md
2021-09-05 11:05:49 +09:00
Masato Ohba 037ddffc26 Merge pull request #14 from ohbarye/dependabot/pip/pygments-2.7.4
Bump pygments from 2.0.2 to 2.7.4
2021-09-05 10:57:52 +09:00
Masato Ohba 859e51c539 Merge pull request #15 from ohbarye/dependabot/pip/bottle-0.12.19
Bump bottle from 0.12.8 to 0.12.19
2021-09-05 10:57:38 +09:00
dependabot[bot] 7324d5ca6c Bump bottle from 0.12.8 to 0.12.19
Bumps [bottle](https://github.com/bottlepy/bottle) from 0.12.8 to 0.12.19.
- [Release notes](https://github.com/bottlepy/bottle/releases)
- [Changelog](https://github.com/bottlepy/bottle/blob/master/docs/changelog.rst)
- [Commits](https://github.com/bottlepy/bottle/compare/0.12.8...0.12.19)

Signed-off-by: dependabot[bot] <support@github.com>
2021-04-07 21:28:18 +00:00
dependabot[bot] 8bdb514add Bump pygments from 2.0.2 to 2.7.4
Bumps [pygments](https://github.com/pygments/pygments) from 2.0.2 to 2.7.4.
- [Release notes](https://github.com/pygments/pygments/releases)
- [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES)
- [Commits](https://github.com/pygments/pygments/compare/2.0.2...2.7.4)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-29 16:48:22 +00:00
ohbarye 4a5a1ff5f6 Update README 2019-10-12 00:05:36 +09:00
Masato Ohba 72ba82b09e Merge pull request #11 from VictorCabello/master
minor maintenance
2019-10-11 23:56:52 +09:00
Victor Cabello 70ece88089 Add support for python3 2019-05-07 00:27:25 -05:00
Victor Cabello db22fbfa34 fix issue with markdwon version 2019-05-06 23:27:42 -05:00
7 changed files with 98 additions and 76 deletions
+2
View File
@@ -0,0 +1,2 @@
markdownserver/resources/html/sample.md.html linguist-documentation
markdownserver/resources/css/github.css linguist-vendored
+2 -3
View File
@@ -12,9 +12,8 @@ How to use
Runtime Environment
--------------------
:Python: 2.7.9
:pip: 6.1.1
:virtualenv: 12.1.1
:Python: 3.7
:pip: 19.1.1
--------------------
+16 -7
View File
@@ -1,23 +1,32 @@
from bottle import route,run,template,static_file
from markdown_converter import MarkdownConverter
from env import *
from __future__ import absolute_import
from bottle import route, run, static_file
from .markdown_converter import MarkdownConverter
from .env import root_path, ms_host, ms_port, ms_debug
import os
converter = MarkdownConverter()
@route('/<resource:re:.*\.md>')
@route(r'/<resource:re:.*\.md>')
def gfmize(resource):
if resource == 'favicon.ico':
return ''
html_file_name = os.path.basename(converter.convert(resource))
if '/' in resource:
html_file_name = '/'.join(resource.split('/')[:-1]) + '/' + html_file_name
return static_file(os.path.join('resources/html', html_file_name), root=root_path)
html_file_name = '/'.join(resource.split('/')[:-1]) + \
'/' + html_file_name
return static_file(os.path.join('resources/html',
html_file_name),
root=root_path)
def main():
run(host=ms_host,port=ms_port,debug=ms_debug,reloader=ms_reloader)
run(host=ms_host,
port=ms_port,
debug=ms_debug,
reloader=False)
if __name__ == '__main__':
main()
+10 -10
View File
@@ -1,16 +1,16 @@
import os
ms_encoding = 'utf-8'
ms_port = '8009'
ms_host = 'localhost'
ms_encoding = "utf-8"
ms_port = "8009"
ms_host = "localhost"
ms_debug = True
ms_reloader = True
html_extension = '.html'
html_extension = ".html"
root_path = os.path.dirname(__file__)
resource_dir = os.path.join(root_path,'resources')
markdown_dir = os.path.join(resource_dir,'markdown')
html_dir = os.path.join(resource_dir,'html')
css_dir = os.path.join(resource_dir,'css')
css_name = 'github.css'
resource_dir = os.path.join(root_path, "resources")
markdown_dir = os.path.join(resource_dir, "markdown")
html_dir = os.path.join(resource_dir, "html")
css_dir = os.path.join(resource_dir, "css")
css_name = "github.css"
css_path = os.path.join(css_dir, css_name)
markdown_type = 'gfm'
markdown_type = "gfm"
+29 -15
View File
@@ -1,38 +1,50 @@
from __future__ import print_function
from __future__ import absolute_import
from builtins import object
import markdown as md
import codecs
import sys
import os
from env import *
from .env import css_path, ms_encoding, markdown_type, \
html_dir, html_extension
class MarkdownConverter(object):
def __init__(self):
css = codecs.open(css_path,encoding=ms_encoding,mode='r')
self.html_header = '''
css = codecs.open(css_path, encoding=ms_encoding, mode="r")
self.html_header = (
"""
<html>
<head>
<style type='text/css'>
<!--
''' + css.read() + \
'''
"""
+ css.read()
+ """
//-->
</style>
</head>
<body>
<div class='markdown-body'>
'''
self.html_footer = '''
"""
)
self.html_footer = """
</div>
</body>
</html>
'''
"""
def convert(self, src, dst=""):
code = md.markdown(self.read_md(src), extensions=[markdown_type])
return self.write_html(code, src, dst)
def read_md(self, file_name):
md_file = codecs.open(os.path.join(markdown_dir, file_name),encoding=ms_encoding,mode='r')
workingdir = os.getcwd()
md_file = codecs.open(
os.path.join(workingdir, file_name),
encoding=ms_encoding,
mode="r"
)
return md_file.read()
def write_html(self, body, file_name, dst):
@@ -41,21 +53,23 @@ class MarkdownConverter(object):
if dst != "":
html_path = dst
try:
os.makedirs('/'.join(html_path.replace('\\', '/').split('/')[:-1]))
except OSError as exc:
os.makedirs("/".join(html_path.replace("\\", "/").split("/")[:-1]))
except OSError:
pass
html_file = codecs.open(html_path,encoding=ms_encoding,mode='w')
html_file = codecs.open(html_path, encoding=ms_encoding, mode="w")
html_file.write(self.html_header + body + self.html_footer)
return html_path
def main():
args = sys.argv
if len(args) != 3:
print('usage: convert source_md_file target_html_file')
print("usage: convert source_md_file target_html_file")
else:
converter = MarkdownConverter()
converter.convert(args[1], args[2])
if __name__ == '__main__':
if __name__ == "__main__":
main()
+2 -2
View File
@@ -1,9 +1,9 @@
bottle==0.12.8
bottle==0.12.19
linecache2==1.0.0
Markdown==2.6.2
-e git+https://github.com/ohbarye/markdown-server@f85a63ba06ca7cb5beb59bd96153d7ba1fa867ae#egg=markdownserver-master
py-gfm==0.1.0
Pygments==2.0.2
Pygments==2.7.4
six==1.9.0
traceback2==1.4.0
unittest2==1.0.1
+23 -25
View File
@@ -1,44 +1,42 @@
import os
from setuptools import setup, find_packages
def read_file(filename):
basepath = os.path.dirname(os.path.dirname(__file__))
filepath = os.path.join(basepath, filename)
if os.path.exists(filepath):
return open(filepath).read()
else:
return ''
return ""
setup(
name = 'markdown-server',
version = '0.1.3',
description = 'A simple markdown server.',
long_description = read_file('README.rst'),
author = 'Masato Ohba',
author_email = 'over.rye@gmail.com',
url = 'https://github.com/ohbarye/markdown-server',
name="markdown-server",
version="0.1.4",
description="A simple markdown server.",
long_description=read_file("README.rst"),
author="Masato Ohba",
author_email="over.rye@gmail.com",
url="https://github.com/ohbarye/markdown-server",
classifiers=[
'Topic :: Utilities',
'Development Status :: 4 - Beta',
'Framework :: Bottle',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
"Topic :: Utilities",
"Development Status :: 4 - Beta",
"Framework :: Bottle",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
],
packages=find_packages(),
include_package_data=True,
keywords = ['web', 'markdown'],
license = 'MIT License',
install_requires = [
'bottle',
'Markdown',
'Pygments',
'py-gfm',
],
keywords=["web", "markdown"],
license="MIT License",
install_requires=["bottle", "Markdown==2.6.11", "Pygments", "py-gfm"],
entry_points={
'console_scripts': [
'markdownserver = markdownserver:main',
'convert = markdownserver.markdown_converter:main'
"console_scripts": [
"markdownserver=markdownserver:main",
"convert=markdownserver.markdown_converter:main",
]
},
)