Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for formatting codes in table cells #17

Open
tbrowder opened this issue Aug 3, 2016 · 15 comments
Open

Add support for formatting codes in table cells #17

tbrowder opened this issue Aug 3, 2016 · 15 comments
Labels
external Things that actually do not depend on us.

Comments

@tbrowder
Copy link
Member

tbrowder commented Aug 3, 2016

Pod formatting codes are either ignored or handled improperly in table cells.

@atroxaper
Copy link

It is not supported in Grammar yet.

@tisonkun
Copy link
Member

tisonkun commented Nov 8, 2017

@atroxaper could you please provide a sample case? what the pod6 code is and how you wish it to be(after render)

@AlexDaniel
Copy link
Member

@W4anD0eR96 here is an example: https://docs.perl6.org/language/variables#Dynamic_variables
That table contains a bunch of pod6 formatting and is currently rendered incorrectly.

@tisonkun
Copy link
Member

tisonkun commented Nov 8, 2017

The root of this problem is not in this repo, but that Pod::Block::Table treats context inside as raw text, see below

Pod::Block::Named{:name("pod")}
  Pod::Block::Table
    $["\$*INIT-INSTANT", "An Instant object representing program startup time. In particular, this is when the core code starts up, so the value of \$*INIT-INSTANT may be a few milliseconds earlier than C<INIT now> or even C<BEGIN now> executed in your program."]
    $["\$*TZ", "The system's local timezone offset, as the number of B<seconds> from GMT"]
    $["\$*CWD", "The Current Working Directory."]
    $["\$*KERNEL", "Which kernel am I running under?"]

@tisonkun
Copy link
Member

tisonkun commented Nov 8, 2017

There is a really ugly way to fix it. By convert

https://github.com/perl6/Pod-To-HTML/blob/0ae43c1fd1c07fac0aafdbc2f074c2b6a8bd6489/lib/Pod/To/HTML.pm#L405-L416

into

    @r.push(
        '<tbody>',
        $node.contents.map(-> $line {
            '<tr>',
            $line.list.map(-> $cell {
              use MONKEY-SEE-NO-EVAL;
              my $local-pod = EVAL("=begin pod\n"~$cell ~ "\n=end pod\n\$=pod");
                "<td>{node2html($local-pod)}</td>"
            }),
            '</tr>'
        }),
        '</tbody>',
        '</table>'
    );

I don't want to apply it at all.

@tisonkun
Copy link
Member

tisonkun commented Nov 8, 2017

@tbrowder works on rakudo/rakudo#1240 , that will fix this issue.

@tbrowder
Copy link
Member Author

tbrowder commented Nov 8, 2017

I’m afraid my work will not help this problem. The only thing my PR does, in regards to format codes, is remove in-line Z<> comments. I can think of some other solutions but it will require some help from core devs. How about writing a new sub named somethng like ‘tablecell2html’ which would take care of the formatting?

Update

After my PR #1240 is merged (if ever), I have proposed a fix for this issue (and volunteered to work on it) on IRC #perl6-dev. So far haven’t received any response, but they are real busy fixing blockers for the next rakudo release.

@tbrowder
Copy link
Member Author

tbrowder commented Jul 12, 2018

Rakudo changes after merge of recent PR #1300 originally by llfourne (made compatible by softmoth) have made formatting codes easier to deal with.

This issue should be revisited.

I'll try to take it on after I get one other p6 doc project working (Language grouping and sorting).

@finanalyst
Copy link

finanalyst commented Dec 3, 2018

As mentioned by TisonKun, the problem is not in this module.
All content of cells is given as text. I think it should be returned as a Pod::Block, which would then allow the Pod renderer to pass the contents to another handler. If the Block contains formating code, this can then be rendered as needed. Currently, a Pod renderer cannot detect what is inside a text cell without parsing the content. Parsing content should not be happening in the renderer.

Simple test:

    =begin table :class<sorttable>

      H1    H2
      --    --
      col1  B<col2>

      I<col1>  col2

    =end table

should lead to something like

/
    '<table class="pod-table sorttable">'
    \s*   '<thead>'
    \s*     '<tr>'
    \s*       '<th>H1</th>'
    \s*       '<th>H2</th>'
    \s*     '</tr>'
    \s*   '</thead>'
    \s*   '<tbody>'
    \s*     '<tr>'
    \s*       '<td><strong>col1</strong></td>'
    \s*       '<td>col2</td>'
    \s*     '</tr>'
    \s*     '<tr>'
    \s*       '<td><em>col1</em></td>'
    \s*       '<td>col2</td>'
    \s*     '</tr>'
    \s*   '</tbody>'
    \s* '</table>'
    /

@JJ
Copy link

JJ commented Dec 3, 2018 via email

@tbrowder
Copy link
Member Author

tbrowder commented Dec 3, 2018

Roger. A know problem on my TODO list.

@JJ JJ added the external Things that actually do not depend on us. label Nov 3, 2019
@JJ
Copy link

JJ commented Nov 3, 2019

Is there any change here?

@tbrowder
Copy link
Member Author

tbrowder commented Nov 3, 2019

Not by me, and I'm not sure I'll ever be able to do it. The grammar is very messy in that area and it needs a large refactoring to make it feasible IMHO. In fact, I'm not sure it was ever in the original design because, in S26, it is not mentioned in the section on tables (which are described as a simple object: "Simple tables [emphasis added] can be specified in Pod using a =table block....").

Additionally, Damian (the S26 author) says of formatting codes, "Formatting codes provide a way to add inline mark-up to a piece of text within the contents of (most types of [emphasis added]) Pod block (including all declarator blocks [emphasis added])." [another NYI feature!]

@coke
Copy link

coke commented Nov 13, 2022

When this is resolved please ping the referenced Raku/doc ticket so we can consider re-adding the links.

@JJ
Copy link

JJ commented Mar 11, 2024

Going over open issues, is there anything that can be done here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
external Things that actually do not depend on us.
Projects
None yet
Development

No branches or pull requests

8 participants