Skip to content

Commit

Permalink
support AsciiDoc README
Browse files Browse the repository at this point in the history
  • Loading branch information
zhenghaoz committed Nov 5, 2024
1 parent f895ae3 commit 49af65f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import concurrent.futures
import io
import json
import logging
import os
import sys
from datetime import datetime
from typing import List, Optional

import asciidoc3
import emoji
import gorse
import mistune
from asciidoc3.asciidoc3api import AsciiDoc3API
from bs4 import BeautifulSoup
from docutils.core import publish_parts
from flask import Flask, Response, session, redirect, request, flash
Expand Down Expand Up @@ -178,6 +181,13 @@ def get_repo(category: str = ""):
content = repo.get_readme().decoded_content.decode("utf-8")
if download_url.endswith(".rst"):
html = publish_parts(content, writer_name="html")["html_body"]
elif download_url.endswith(".asciidoc"):
infile = io.StringIO(content)
outfile = io.StringIO()
asciidoc3api = AsciiDoc3API(asciidoc3.__path__[0] + '/asciidoc3.py')
asciidoc3api.options('--no-header-footer')
asciidoc3api.execute(infile, outfile, backend='html4')
html = outfile.getvalue()
else:
html = mistune.html(content)
soup = BeautifulSoup(html, "html.parser")
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
asciidoc3==3.2.3
beautifulsoup4==4.9.3
celery==5.2.7
docutils==0.17.1
emoji==1.6.1
Flask==2.3.2
flask-cors==4.0.2
Flask-Dance[sqla]==6.2.0
flask-login==0.6.0
flask-login==0.6.3
Flask-SQLAlchemy==2.5.1
gevent==23.9.1
gunicorn==22.0.0
Expand Down

0 comments on commit 49af65f

Please sign in to comment.