Giter Club home page Giter Club logo

weekly-tg's Introduction

weekly-tg

自动生成科技爱好者周刊 telegram channel推送, see issue #885.

License (注:这个Licence继承自这个仓库,只针对代码内容,不针对weekly博文)。

依赖

安装依赖:

pip/pip3 install -r requirements.txt

如果想尝试替换markdown => html 模块,可以安装:

# optional: pandoc - markdown => html
apt-get install pandoc

# optional: python markdown module
apt-get install python3-markdown

下载博客文本内容:

git pull --recurse-submodules

功能

  • 文本处理:将博文成批转处理,获得标题+修改过后的内容(在末尾加上tg channel promt).
  • 文本转换:将markdown格式转换成html (issue1),以适应telegraph api.
  • 使用telegram bot自动推送

使用说明

├── generate-post.py	# python script to generate posts in batch
├── md2html.py			# convert md to html, following principles of tg API
├── LICENSE
├── README.md
├── requirements.txt
├── run.sh				# run python script with proxychains: needed under GFW
├── TODO
├── venv
└── weekly				# original posts

使用:

python generate-post.py [starting-index] [ending-index]

来成批生成telegraph博文。

使用:

./run.sh [starting-index] [ending-index]

使用proxychains运行此python脚本。

合作

这个仓库的代码的目的是让tg channel管理员能够相对轻松地搬运博文,但是它也可以成为从markdown源文件部署tg channel推送的一个项目。非常欢迎有意贡献代码的小伙伴们参与!

问题

1. Markdown => html

我尝试了这个仓库 (即pandoc) 和python模块markdown (命令行),但是它们对引用的处理都有问题,左侧没有横杠出现/横岗出现得一点都不美观,缩进也有点问题,我觉得这个小问题 可以忍受 有点不能忍受。可能我们需要寄希望于typora开发出高级命令行功能了。 我决定尝试一下使用re模块,就像这个repo一样。

Telegraph提供接口:content/html_content,接受DOM Node array,详情见这里:它只接受有限的tags: a, aside, b, blockquote, br, code, em, figcaption, figure, h3, h4, hr, i, iframe, img, li, ol, p, pre, s, strong, u, ul, video. 这样看来为它写一个专用的parser比较可行。

  • 链接最长匹配
  • 引用block缩进: 直接复制也有这个问题,这是tg的渲染问题。
  • 列表:weekly中使用--表示"by",所以列表有问题,已经删除相关parsing.

weekly-tg's People

Contributors

dependabot[bot] avatar eltsai avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Forkers

borber

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.