OneMore icon indicating copy to clipboard operation
OneMore copied to clipboard

Markdown improvements regarding tables, nested statements and special character support in links

Open weissm opened this issue 1 year ago • 6 comments
trafficstars

IS YOUR COMMIT SIGNED?

yes

Enhancement or Defect Addressed by This PR

Enhancement

Description of Proposed Changes

When generating markdown nested tables the handled was not done properly. Also the handling of numbered list in tables was not properly processed. The following changes are applied:

  • A Class PrefixClass is introduced to pass sticky parameters by reference.
  • The actual writing of text was pushed to the "T" object.
  • The anchor link is now surrounded by <>. To protect these characters, the Replace statement is moved before.

The push requested was tested on the OneNote TextToTable. For clarification another example onenote page NestedTableContent is added.

weissm avatar Oct 31 '24 19:10 weissm

I will take a look at this. Just need a little time. Thanks!

stevencohn avatar Nov 05 '24 21:11 stevencohn

@weissm Using your Nested Tables example page, this results in markdown as follows, with a table header divider line after the table, not before:

| **🛈**   | **Test Protocol**  Markdown generation of nested tables  <ol><li>Here is a nested table</li><li>Export this to an Markdown file or Copy as Markdown</li><li>Confirm that a netsted table is generate</li></ol> |  |  | 
|  :--- | :--- | :--- | :--- |

and when converted back to OneNote content, looks like this:

image

The divider line should be removed, or before the table and translated to an actual divider

stevencohn avatar Nov 07 '24 19:11 stevencohn

@weissm This PR is now far beyond the original intent described by the title. I cannot accept this as a single PR.

stevencohn avatar Nov 24 '24 17:11 stevencohn

@weissm This PR is now far beyond the original intent described by the title. I cannot accept this as a single PR.

Understood. This PR extension was meant to address: @weissm Using your Nested Tables example page, this results in markdown as follows, with a table header divider line after the table, not before:

Will create separate PRs to ease handling.

weissm avatar Nov 24 '24 19:11 weissm

Reworked the complete change set in cluster changes into indivdiual commits.

weissm avatar Nov 28 '24 20:11 weissm

Should be possible to move it into one loop. This structure is applied more for historical reasons.

From: Steven @.> Sent: Saturday, January 11, 2025 8:09 PM To: stevencohn/OneMore @.> Cc: Matthias Weiss @.>; Mention @.> Subject: Re: [stevencohn/OneMore] Markdown improvements regarding tables, nested statements and special character support in links (PR #1647)

@stevencohn commented on this pull request.


In OneMore/Commands/File/Markdown/MarkdownConverter.cs https://github.com/stevencohn/OneMore/pull/1647#discussion_r1912170164 :

  •                                                // ensure TagDef exists
    
  •                                                var index = page.AddTagDef("3", "To Do", 4);
    
  •                                                // inject tag prior to run
    
  •                                                 run.AddBeforeSelf(new Tag(index, match.Groups["x"].Value == "x"));
    
  •                                                var org = text.Value;
    
  •                                                var completed = match.Groups["x"].Value == "x";
    
  •                                                text.Value = text.Value.Replace((completed ? "[x]" : "[ ]"), "");
    
  •                                                cdata.Value = cdata.Value.Replace(org, text.Value);
    
  •                                                 page.SetTag(paragraph, tagSymbol: "3", tagStatus:completed,tagName:"todo");
    
  •                                         }
    
  •                                         else
    
  •                                         {
    
  •                                                // look for all other tags
    
  •                                                foreach (var t in MarkdownEmojis.taglist)
    

You're updating ToDo tags, or all other tags, but not both. Should this all be collapsed down into a single loop that just touches all tags? Then you can handle todo tags inside that loop while still addressing all others too.

— Reply to this email directly, view it on GitHub https://github.com/stevencohn/OneMore/pull/1647#pullrequestreview-2545133318 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ABAGSHA5RR6O2Y42PQVQMZD2KFT43AVCNFSM6AAAAABQ7AG2W2VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKNBVGEZTGMZRHA . You are receiving this because you were mentioned. https://github.com/notifications/beacon/ABAGSHHZB24RZFTXY7M3YUD2KFT43A5CNFSM6AAAAABQ7AG2W2WGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTUXWOTQM.gif Message ID: @.*** @.***> >

weissm avatar Jan 13 '25 07:01 weissm