l1xnan / obsidian-better-export-pdf

Obsidian PDF export enhancement plugin
MIT License
364 stars 22 forks source link

How to print PDF with HTML <span> tag color-background effect INSIDE A TABLE #346

Closed arieltutu closed 1 week ago

arieltutu commented 3 weeks ago

First off, thank you for this fantastic plugin! It’s a huge help, especially since exporting notes to PDF with emoji or Twemoji via Pandoc can be quite complicated and doesn’t always work as expected. Additionally, maintaining outline structure in PDF is really convenient. I'm a programming noob. From what I understand, Pandoc converts Markdown to LaTeX (which lacks native emoji support) before generating a PDF, which often causes issues. See Pandoc official description: https://pandoc.org/MANUAL.html#creating-a-pdf


In plugin settings, I have toggled on "Print Background" already.

My Problem:

So I try to export my note with HTML <span> tag code that include inline text with multiple background colors inside a table. Well, <span> background-color works fine with plain text, but not within a table after exporting. Here’s how it looks in the Obsidian preview: {F08FEB92-C632-4421-B104-60CF34FA847F} P.S.: I tried using <mark> tags instead, but it only highlights text with a single background color (yellow) rather than multiple colors after rendering or exporting: {67BD201A-F540-4427-ADED-6B047EDAEFEB}


Question:

Is it correct to assume that <span style="background-color: ..."> type anything </span>is unsupported inside a tale in the export? My obsidian source mode: {502195D9-E66F-4210-9A12-7DF8EC614456}

Here is what I get after <span> backgoud-color typing exporting: {89371763-455F-41CC-960B-836D59198942}

Or if there are any possible solutions I can get to display inline text background colors inside a table?

arieltutu commented 3 weeks ago

For exporting emoji contained note to PDF via Pandoc plugin, I also tried this Emoji from Obsidian markup to LaTeX via Pandoc #193, but it didn't work for me.

arieltutu commented 3 weeks ago

I also tried converting the note to HTML first and then print HTML to PDF via browser, but it resulted in the outline structure being lost, which is not what I'm looking for.

arieltutu commented 3 weeks ago

谢谢啦 zfb支持了一下 😄

l1xnan commented 3 weeks ago

太客气了,感谢支持!Markdown 笔记文件是支持 HTML 片段的,背景颜色可以正常显示,没有复现你的问题,能提供下样例文件么?

New para<font color="#e36c09">graph</font>

| Header1                                        | Header2 |
| ---------------------------------------------- | ------- |
| 🐸R1C1                                         | R1C2    |
| 🐱<span style="background:#ff4d4f">R2</span>C1 | R2C2    |
| 🐹R3<span style="background:#ff4d4f">C1</span> | R3C2    |

image

arieltutu commented 3 weeks ago

Highlights, annotations

| highlights, annotations                                   | tags                                                                                                                                                                                                                                                           | text                                                                                                    |
| --------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| <mark>gold</mark>                                         | 👁️‍🗨️<span style="background-color: #FFF3A3A6;">discern</span><br>🪙<span style="background-color: #FFF3A3A6;">Standard</span>                                                                                                                               | <mark>highlight</mark>                                                                                  |
| <span style="background-color: #FF5582A6;">red</span>:    | 🆚<span style="background-color: #FF5582A6;">comparison, contrast</span>                                                                                                                                                                                       | ❌<span style="background-color: #FF5582A6;">False</span><br><font color=red>contrast, comparison</font> |
| <span style="background-color: #BBFABBA6;">green</span>:  | ⚕<span style="background-color: #BBFABBA6;">condition</span><br>🩺<span style="background-color: #BBFABBA6;">diagnosis</span><br>💉<span style="background-color: #BBFABBA6;">Treatment</span><br>♻<span style="background-color: #BBFABBA6;">mechanism</span> | ✅<span style="background-color: #BBFABBA6;">True</span>                                                 |
| <span style="background-color: #ABF7F7A6;">cyan</span>:   | 🔤<span style="background-color: cyan">EngTerm</span>                                                                                                                                                                                                          | <font color="#4bacc6">English terminology<br>terminology                                                |
| <span style="background-color: #D2B3FFA6;">purple</span>: | 🔢<span style="background-color: #D2B3FFA6;">statistics</span><br>🚪<span style="background-color: #D2B3FFA6;">threshold</span>                                                                                                                                |                                                                                                         |
| <span style="background-color: #FFB8EBA6;">pink</span>:   | 🧠<span style="background-color: pink">Mnemonics</span>                                                                                                                                                                                                        | <font color= magenta>~abstract</font>                                                                   |
| <span style="background-color: #FFB86CA6;">orange</span>: | 🔑<span style="background-color: orange">KEY POINT</span><br>comparison                                                                                                                                                                                        | <span style="background-color: #FFB86CA6;">review</span>                                                |
| <span style="background-color: #CACFD9A6;">grey</span>:   |                                                                                                                                                                                                                                                                | 🗒<font color="#a5a5a5">descriptions, insinuations                                                      |
| **black**:                                                |                                                                                                                                                                                                                                                                | ✒text                                                                                                   |
l1xnan commented 3 weeks ago

@arieltutu 没有复现,奇怪 image

arieltutu commented 1 week ago

@arieltutu 没有复现,奇怪 image

排查了一下 应该是我装这个表格插件的原因 Sheets Extended 关掉就可以打印了