getapi commited on
Commit
808b0b8
1 Parent(s): 585d78c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -119,8 +119,10 @@ def md_to_dom(markdown_text: str) -> list[dict[str, str | list | dict | None]]:
119
  return handler(element)
120
  html_content = markdown(markdown_text, extensions=['extra', 'sane_lists'])
121
  tree = html.fromstring(html_content)
122
- return [parse_element(element) for element in tree.body]
123
-
 
 
124
 
125
  async def tgph_create_page(token: str, title: str, markdown_text: str) -> str:
126
  content = dumps(md_to_dom(markdown_text))
@@ -145,8 +147,6 @@ async def tgph_create_page(token: str, title: str, markdown_text: str) -> str:
145
 
146
  async def tgph_edit_page(token: str, page: str, title: str, markdown_text: str) -> str:
147
  content = dumps(md_to_dom(markdown_text))
148
- print(markdown_text)
149
- print(content)
150
  params = {
151
  'access_token': token,
152
  'path': page,
@@ -334,6 +334,7 @@ async def continue_optimizing_and_uploading(images_urls: list[str], page_id: str
334
  print(f'не удалось удалить файл {images_paths[0].parent}: {e}')
335
 
336
  content = '\n\n'.join([f'![]({url})' for url in new_images_urls])
 
337
  if ph_link:
338
  try:
339
  await tgph_edit_page(tgph_acc.get_token(), ph_link, 'DAll-E v3', content)
 
119
  return handler(element)
120
  html_content = markdown(markdown_text, extensions=['extra', 'sane_lists'])
121
  tree = html.fromstring(html_content)
122
+ try:
123
+ return [parse_element(element) for element in tree.body]
124
+ except:
125
+ return [parse_element(element) for element in tree.xpath('/*/*')]
126
 
127
  async def tgph_create_page(token: str, title: str, markdown_text: str) -> str:
128
  content = dumps(md_to_dom(markdown_text))
 
147
 
148
  async def tgph_edit_page(token: str, page: str, title: str, markdown_text: str) -> str:
149
  content = dumps(md_to_dom(markdown_text))
 
 
150
  params = {
151
  'access_token': token,
152
  'path': page,
 
334
  print(f'не удалось удалить файл {images_paths[0].parent}: {e}')
335
 
336
  content = '\n\n'.join([f'![]({url})' for url in new_images_urls])
337
+ print(content)
338
  if ph_link:
339
  try:
340
  await tgph_edit_page(tgph_acc.get_token(), ph_link, 'DAll-E v3', content)