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

How to parse optional arguments of environments #13

Open
larsgw opened this issue Dec 7, 2024 · 2 comments · May be fixed by #14
Open

How to parse optional arguments of environments #13

larsgw opened this issue Dec 7, 2024 · 2 comments · May be fixed by #14

Comments

@larsgw
Copy link
Contributor

larsgw commented Dec 7, 2024

Description

How can I parse optional arguments of environments in PhpLatex? The following LaTeX:

\begin{tabular}[t]{c}
  table content
\end{tabular}

Gets parsed as follows:

object(App\Utility\Latex\Parser\Node) id:0 {
  protected _type => 'environ'
  protected _props => [
    'mode' => (int) 1,
    'value' => 'tabular',
  ]
  protected _children => [
    (int) 0 => object(PhpLatex_Node) id:1 {
      protected _type => 'group'
      protected _props => [
        'mode' => (int) 1,
        'arg' => true,
      ]
      protected _children => [
        (int) 0 => object(PhpLatex_Node) id:2 {
          protected _type => 'text'
          protected _props => [
            'mode' => (int) 1,
            'value' => '[',
          ]
          protected _children => [ ]
        },
      ]
    },
    (int) 1 => object(PhpLatex_Node) id:3 {
      protected _type => 'text'
      protected _props => [
        'mode' => (int) 1,
        'value' => 't]',
      ]
      protected _children => [ ]
    },
    (int) 2 => object(PhpLatex_Node) id:4 {
      protected _type => 'group'
      protected _props => [
        'mode' => (int) 1,
      ]
      protected _children => [
        (int) 0 => object(PhpLatex_Node) id:5 {
          protected _type => 'text'
          protected _props => [
            'mode' => (int) 1,
            'value' => 'c',
          ]
          protected _children => [ ]
        },
      ]
    },
    (int) 3 => object(PhpLatex_Node) id:6 {
      protected _type => 'text'
      protected _props => [
        'mode' => (int) 1,
        'value' => ' table content ',
      ]
      protected _children => [ ]
    },
  ]
}

Possible Solution

Would I need to do the following?

  1. Get the first child
  2. Check the 'arg' => true prop
  3. See it has a child of type text with value '['
  4. Check the following children until one contains a text node containing the character ']'
  5. Check following child nodes for whether they are also arguments

Is it not possible to parse these args in Parser::_parseArg?

Additional Context

No response

larsgw added a commit to larsgw/php-latex that referenced this issue Dec 7, 2024
larsgw added a commit to larsgw/php-latex that referenced this issue Dec 7, 2024
@larsgw larsgw linked a pull request Dec 7, 2024 that will close this issue
@stale stale bot added the stale Automatically closed due to inactivity label Jan 9, 2025
Repository owner deleted a comment from stale bot Jan 9, 2025
@xemlock xemlock removed the stale Automatically closed due to inactivity label Jan 9, 2025
@stale stale bot removed the stale Automatically closed due to inactivity label Jan 9, 2025
@stale stale bot added the stale Automatically closed due to inactivity label Feb 9, 2025
Repository owner deleted a comment from stale bot Feb 9, 2025
@xemlock xemlock removed the stale Automatically closed due to inactivity label Feb 9, 2025
Copy link

stale bot commented Mar 13, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale Automatically closed due to inactivity label Mar 13, 2025
Copy link

stale bot commented Mar 21, 2025

Closing this issue after a prolonged period of inactivity.

@stale stale bot closed this as completed Mar 21, 2025
@xemlock xemlock reopened this Mar 21, 2025
@stale stale bot removed the stale Automatically closed due to inactivity label Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants