rknj / html2markdown

Github Action converting a HTML file to Markdown
MIT License
4 stars 3 forks source link

Action doesn't produce output file #2

Open vitalyk-multinarity opened 1 year ago

vitalyk-multinarity commented 1 year ago

I'm using this action in my workflow:

- name: Convert HTML to Markdown
        id: html2markdown
        if: always()
        uses: rknj/html2markdown@v0.1.0
        with:
          html-file: "daff-output.html"

I do see markdown output in my job's log, but there is no file produced. I mean - after I didn't see output using "cat ${{ steps.html2markdown.outputs.markdown-file }}", I ran "ls -l" and see nothing.

Please suggest. TIA, Vitaly

rknj commented 1 year ago

Thanks for your feedback. Could you please give a try with rknj/html2markdown@v1.1.0?

vitalyk-multinarity commented 1 year ago

Thank you. My HTML file is:

<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<style TYPE='text/css'>
.highlighter .add { 
  background-color: #7fff7f;
}

.highlighter .remove { 
  background-color: #ff7f7f;
}

.highlighter td.modify { 
  background-color: #7f7fff;
}

.highlighter td.conflict { 
  background-color: #f00;
}

.highlighter .spec { 
  background-color: #aaa;
}

.highlighter .move { 
  background-color: #ffa;
}

.highlighter .null { 
  color: #888;
}

.highlighter table { 
  border-collapse:collapse;
}

.highlighter td, .highlighter th {
  border: 1px solid #2D4068;
  padding: 3px 7px 2px;
}

.highlighter th, .highlighter .header, .highlighter .meta {
  background-color: #aaf;
  font-weight: bold;
  padding-bottom: 4px;
  padding-top: 5px;
  text-align:left;
}

.highlighter tr.header th {
  border-bottom: 2px solid black;
}

.highlighter tr.index td, .highlighter .index, .highlighter tr.header th.index {
  background-color: white;
  border: none;
}

.highlighter .gap {
  color: #888;
}

.highlighter td {
  empty-cells: show;
  white-space: pre-wrap;
}
</style>
</head>
<body>
<div class='highlighter'>
<table>
<thead>
<tr class="header"><th>@@</th><th></th><th>t_rms[mm]</th><th>t_spikes_per_hour@[30](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:31)mm</th><th>...</th><th>keypoint_15_error</th><th>params</th><th>video_names</th></tr>
</thead>
<tbody>
<tr><td></td><td></td><td>t_rms[mm]</td><td>t_spikes_per_hour@30mm</td><td>...</td><td>keypoint_15_error</td><td>params</td><td>video_names</td></tr>
<tr class="modify"><td class="modify">→</td><td>0</td><td>16.778</td><td>94.0[40](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:41)</td><td>...</td><td>5.566</td><td class="modify">&lt;keyboard_tracking.evaluation.kpi_evaluation_metrics.EvaluationParameters object at 0x7fb9cf[49](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:50)e4c0&gt;→&lt;keyboard_tracking.evaluation.kpi_evaluation_metrics.EvaluationParameters object at 0x7f06ec67b3d0&gt;</td><td>['06[53](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:54)_58_keyboard_on_white_desk_high_lux_in_the_shade', '06[54](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:55)_58_low_lighting_paper_occlusion', '06[55](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:56)_[58](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:59)_dark_environment_keyboard_half_lighten_half_dark', '0658_qual_58_white_desk_keyboard_moving', '06[59](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:60)_58_keyboard_on_desk_looking_at_keyboard_different_angles', '06[60](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:61)_58_keyboard_on_desk_only_one_hand_in_FOV_each_time', '06[61](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:62)_58_normal_office_lighting_lap', '06[62](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:63)_58_head_still_keyboard_in_all_parts_of_the_FOV', '06[63](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:64)_58_hand_held_keyboard_partially_out_of_FOV', '06[64](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:65)_58_natural_light_outside_lap', '06[65](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:3:66)_58_flickering_lighting_desk_hand_held_mug_tight_to_keyboard']</td></tr>
</tbody>
</table>
</div>
</body>
</html>

With v1.1.0 I'm getting

Run rknj/html2markdown@v1.1.0
Input file:OUTPUT.html
node:internal/fs/utils:3[4](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:4:5)[5](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:4:6)
    throw err;
    ^

Error: EACCES: permission denied, open '/OUTPUT.md'
    at Object.openSync (node:fs:585:3)
    at Object.writeFileSync (node:fs:21[7](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:4:8)0:35)
    at /home/runner/work/_actions/rknj/html2markdown/v1.1.0/dist/index.js:27[8](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:4:9)15:4
    at /home/runner/work/_actions/rknj/html2markdown/v1.1.0/dist/index.js:2781[9](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:4:10):3
    at Object.<anonymous> (/home/runner/work/_actions/rknj/html2markdown/v1.1.0/dist/index.js:27822:12)
    at Module._compile (node:internal/modules/cjs/loader:1[10](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:4:11)5:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:[11](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:4:12)59:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:[12](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:4:13))
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) {
  errno: -[13](https://github.com/multinarity/vitalytest/actions/runs/4095767877/jobs/7062925577#step:4:14),
  syscall: 'open',
  code: 'EACCES',
  path: '/OUTPUT.md'
}
luizbon commented 3 days ago

For those finding the same issue, this is caused by how the code defines the path to save the MD file. On this line, the code joins the HTML file path with a forward slash. When the HTML file is on the root of the repo, the action tries to save the markdown file to the root of the agent, and it doesn't have access to the agent's root folder. A workaround for this is to use a relative path for the HTML file.

      - name: Convert HTML to Markdown
        id: html2markdown
        if: always()
        uses: rknj/html2markdown@v0.1.0
        with:
          html-file: "./dependency-analysis.html"