mysticmind / reversemarkdown-net

ReverseMarkdown.Net is a Html to Markdown converter library in C#. Conversion is very reliable since HtmlAgilityPack (HAP) library is used for traversing the Html DOM
MIT License
283 stars 67 forks source link

Table convert may be getting wrong #392

Closed himadrinath closed 4 months ago

himadrinath commented 4 months ago

@mysticmind

html

<ol>
    <li>
        <p>
            Measurements in the same patient can show physiological &amp; analytical variations. Three serial samples 1 week apart are recommended for Total Cholesterol, Triglycerides, HDL &amp; LDL Cholesterol.
        </p>
    </li>
    <li>
        <p>
            Lipid Association of India (LAI) recommends screening of all adults above the age of 20 years for Atherosclerotic Cardiovascular Disease (ASCVD) risk factors especially lipid profile. This should be done earlier if there is family history of premature heart disease, dyslipidemia, obesity or other risk factors
        </p>
    </li>
</ol>
<h3>
    ASCVD Risk Stratification &amp; Treatment goals in Indian population
</h3>
<ol>
    <li>
        <p>
            Indians are at very high risk of developing ASCVD, they usually get the disease at an early age, have a more severe form of the disease and have poorer outcome as compared to the western populations
        </p>
    </li>
    <li>
        <p>
            Many individuals remain asymptomatic before they get heart attack, ASCVD risk helps to identify high risk individuals even when there is no symptom related to heart disease
        </p>
    </li>
    <li>
        <p>
            ASCVD risk category helps clinician to decide when to consider therapy and what should be the treatment goal
        </p>
    </li>
</ol>
<h3 style="text-align: center">
    <mark>
        Treatment Goals as per Lipid Association of India 2020
    </mark>
</h3>
<table class="tiptap" style="minWidth: 125px">
    <colgroup>
        <col>
            <col>
                <col>
                    <col>
                        <col>
                        </col>
                        <tbody>
                            <tr>
                                <th colspan="1" rowspan="2">
                                    <p style="text-align: center">
                                        ASCVD RISK&nbsp;
                                    </p>
                                    <p style="text-align: center">
                                        CATEGORY@
                                    </p>
                                </th>
                                <th colspan="2" rowspan="1">
                                    <p style="text-align: center">
                                        CONSIDER THERAPY
                                    </p>
                                </th>
                                <th colspan="2" rowspan="1">
                                    <p style="text-align: center">
                                        TREATMENT GOAL
                                    </p>
                                </th>
                            </tr>
                            <tr>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        LDL CHOLESTEROL
                                    </p>
                                    <p style="text-align: center">
                                        (LDL-C)(mg/dL)
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        NON HDL CHLOESTEROL
                                    </p>
                                    <p style="text-align: center">
                                        (NON HDL-C) (mg/dL)
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        LDL CHOLESTEROL
                                    </p>
                                    <p style="text-align: center">
                                        (LDL-C)(mg/dL)
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        NON HDL CHLOESTEROL
                                    </p>
                                    <p style="text-align: center">
                                        (NON HDL-C) (mg/dL)
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        Extreme (A)
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=50
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=80
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;50 (Indispensable)
                                    </p>
                                    <p style="text-align: center">
                                        &lt;30 (Optional)
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;80
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        Extreme (B)
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=30
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=60
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;30
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;60
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        Very High
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=50
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=80
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;50
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;80
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        High
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=70
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=100
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;70
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;100
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        Moderate
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=100
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=130
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;100
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;130
                                    </p>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        Low
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=130*
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &gt;=160*
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;100
                                    </p>
                                </td>
                                <td colspan="1" rowspan="1" style="background-color: null">
                                    <p style="text-align: center">
                                        &lt;130
                                    </p>
                                </td>
                            </tr>
                        </tbody>
                    </col>
                    <p>
                        * In low risk patient, consider therapy after an initial non-pharmacological intervention for at least 3 months
                    </p>
                    <p>
                    </p>
                    <p>
                        <strong>
                            @To know your risk category click on bit.ly link sent on your registered mobile number, answer the questionnaire, the ASCVD risk report can be downloaded from website.
                        </strong>
                    </p>
                </col>
            </col>
        </col>
    </colgroup>
</table>

getting

1. Measurements in the same patient can show physiological & analytical variations. Three serial samples 1 week apart are recommended for Total Cholesterol, Triglycerides, HDL & LDL Cholesterol.
2. Lipid Association of India (LAI) recommends screening of all adults above the age of 20 years for Atherosclerotic Cardiovascular Disease (ASCVD) risk factors especially lipid profile. This should be done earlier if there is family history of premature heart disease, dyslipidemia, obesity or other risk factors

### ASCVD Risk Stratification & Treatment goals in Indian population

1. Indians are at very high risk of developing ASCVD, they usually get the disease at an early age, have a more severe form of the disease and have poorer outcome as compared to the western populations
2. Many individuals remain asymptomatic before they get heart attack, ASCVD risk helps to identify high risk individuals even when there is no symptom related to heart disease
3. ASCVD risk category helps clinician to decide when to consider therapy and what should be the treatment goal

### <mark>Treatment Goals as per Lipid Association of India 2020</mark>

| ASCVD RISK <br><br>CATEGORY@ | CONSIDER THERAPY | TREATMENT GOAL |
| --- | --- | --- |
| LDL CHOLESTEROL<br><br>(LDL-C)(mg/dL) | NON HDL CHLOESTEROL<br><br>(NON HDL-C) (mg/dL) | LDL CHOLESTEROL<br><br>(LDL-C)(mg/dL) | NON HDL CHLOESTEROL<br><br>(NON HDL-C) (mg/dL) |
| Extreme (A) | &gt;=50 | &gt;=80 | &lt;50 (Indispensable)<br><br>&lt;30 (Optional) | &lt;80 |
| Extreme (B) | &gt;=30 | &gt;=60 | &lt;30 | &lt;60 |
| Very High | &gt;=50 | &gt;=80 | &lt;50 | &lt;80 |
| High | &gt;=70 | &gt;=100 | &lt;70 | &lt;100 |
| Moderate | &gt;=100 | &gt;=130 | &lt;100 | &lt;130 |
| Low | &gt;=130\* | &gt;=160\* | &lt;100 | &lt;130 |

\* In low risk patient, consider therapy after an initial non-pharmacological intervention for at least 3 months

**@To know your risk category click on bit.ly link sent on your registered mobile number, answer the questionnaire, the ASCVD risk report can be downloaded from website.**
mysticmind commented 4 months ago

@himadrinath If the table uses colspan, the conversion won't work well since there is no support for it in terms of markdown. Only if the table has same number of columns as count in both header row and data rows will work.

You may need to do some pre-processing of the source HTML to have the same number of columns in both header and data rows without the use of colspan before you send it for conversion to markdown.

mysticmind commented 4 months ago

One other possible workaround for conversion is to duplicate the header column having colspan more than 1 to have the same thing split into multiple columns with the same info so that colspan is not used.

mysticmind commented 4 months ago

Functionality available in v4.5.0