NotePlan / NotePlan/plugins

Templating - Web Service Call and Markdown Tables

Open
#517 2 comments 0 reactions 1 assignee View on GitHub

@mikeerickson is already working on this.

Since Jan 17, 2024.

bug
Dominant language
JavaScript
Stars
204
Forks
82
Avg merge
22h 27m
Merged PRs (30d)
3

Description

Describe the bug

I have a weird scenario with this call.


<%- await web.services(fullURL) %>

I have been creating some custom web services that I can call in my templates to gather data for me. I can't stand javascript so I do this in another language (go) and deploy them out to a custom container in the cloud so I can just call the simple web service and have it return markdown content. This makes my life easier.

I have a web service that is returning a valid markdown table. However, when I call it in my template, it is not rendering the table. It is removing a line break between the column names and the column separator.

If you put this in a template and run it, you will see that the table is not rendering correctly. If you run the curl command, you will see that the table is rendering correctly.

<%- await web.services('https://personal-noteplan.fly.dev/randomtable') %>

The text that gets input into the note is this. See the missing line break between the column names and the column separator.

| Column 1 | Column 2 | Column 3 || --- | --- | --- |
| 3 | 37 | 18 |
| 0 | 23 | 90 |
| 87 | 10 | 80 |
| 5 | 79 | 78 |
| 81 | 41 | 51 |
| 56 | 27 | 6 |
| 57 | 49 | 1 |
| 89 | 76 | 46 |
| 19 | 43 | 83 |
| 33 | 11 | 7 |

Here if you call the curl command.

curl https://personal-noteplan.fly.dev/randomtable

You can see that the markdown table is rendering correctly from the web service.

| Column 1 | Column 2 | Column 3 |
| --- | --- | --- |
| 20 | 66 | 91 |
| 53 | 68 | 20 |
| 57 | 57 | 96 |
| 76 | 95 | 0 |
| 81 | 53 | 76 |
| 45 | 36 | 81 |
| 60 | 40 | 87 |
| 19 | 33 | 0 |
| 5 | 28 | 82 |
| 1 | 95 | 53 |

It is funny that this is only an issue with the separator between the column names and the column separator.

To Reproduce

See above

Expected behavior

The markdown should not be changed. It should take the line breaks as is.

Screenshots

N/A

System

  • Device: Mac
  • OS: macOS Latest
  • NotePlan Version latest
  • Plugin Name & Version np.Templating-v1.10.1

Additional context

Plugin Console Log

To provide us with more clues about where the bug/error is occurring...

  1. Open the Plugin's Preferences by going to NotePlan's menu > Preferences > Plugins and clicking the settings "cog" icon next to the plugin in question. Scroll to the bottom and set the logging level to "DEBUG" and click "Save & Close"
  2. Now open the Plugin Console by going to Noteplan > Help > Plugin Console
  3. Run the plugin command you're reporting
  4. Copy the output from the Plugin Console and paste it below
  5. Delete any output that has personal information you don't want in there
2024-01-16 17:08:54 | DEBUG | np.MeetingNotes Plugin Settings :: {
  "_pluginID": "np.MeetingNotes",
  "_logLevel": "LOG"
}
Executing function 'insertNoteTemplate'
2024-01-16 17:08:54 | DEBUG | np.MeetingNotes v1.2.1 :: insertNoteTemplate
2024-01-16 17:08:54 | DEBUG | np.MeetingNotes v1.2.1 :: 8ms - chooseTemplateIfNeeded
2024-01-16 17:08:54 | DEBUG | np.MeetingNotes v1.2.1 :: 8ms - no template was defined, find all available templates and show them
2024-01-16 17:08:54 | DEBUG | np.MeetingNotes v1.2.1 :: 8ms templateFolder @Templates
2024-01-16 17:08:54 | DEBUG | np.MeetingNotes v1.2.1 :: 10ms notes 345
2024-01-16 17:08:54 | DEBUG | np.MeetingNotes v1.2.1 :: 11ms allTemplates 12
2024-01-16 17:08:54 | DEBUG | np.MeetingNotes v1.2.1 :: 11ms - 12 templates found
2024-01-16 17:08:54 | DEBUG | np.MeetingNotes v1.2.1 :: 18ms - of those, 12 are non-ignore templates
2024-01-16 17:08:54 | DEBUG | np.MeetingNotes v1.2.1 :: 18ms - asking user to select from 12  templates ...
2024-01-16 17:08:56 | DEBUG | np.MeetingNotes v1.2.1 :: get content of template for rendering
2024-01-16 17:08:56 | DEBUG | np.MeetingNotes v1.2.1 :: preRender() template
2024-01-16 17:08:56 | DEBUG | np.MeetingNotes v1.2.1 :: render() template
2024-01-16 17:08:57 | DEBUG | np.MeetingNotes v1.2.1 :: apply rendered template to the current editor

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.