首页 > 解决方案 > Telegraph API 中的格式化列表

问题描述

在一个系统上工作,包括通过 python 在 Telegraph 上发布文章。一般来说,一切正常。但最近我发现 <ol> 和 <ul> 标签在不同浏览器中的奇怪行为。在 Telegraph 的移动版本上,它按预期工作,而在其他任何地方都没有。除了对行数进行硬编码外,还有其他解决方案吗?您可以在此处自行查看https://telegra.ph/Arthur-Conan-Doyle-Estudio-en-Escarlata-1-09-06(自 2021 年 10 月 5 日起生效)。我正在使用的代码如下:

def update_page(path, title, content, author):
  response = telegraph.edit_page(path, html_content = content, title = title,
                               author_name = author, return_content=True)
  current_path = 'http://telegra.ph/{}'.format(path)
  return current_path 

html = '''
<ol>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ol>
<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>
'''
title = 'Testing lists'
update_page(test_path, title, html, AUTHOR)

行为示例: 我需要的行为,Telegraph 的移动版本,这是 我在 Chrome、Firefox 和 Safari 中得到的

标签: pythonhtmltelegramtelegram-bottelegraph

解决方案


尝试将列表项写在一行中,例如 <li>1</li><li>2</li><li>3</li>。这为我解决了。


推荐阅读