public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* MediaWiki to Markdown conversion
@ 2020-04-14 22:57 sal
       [not found] ` <79af9e1a-acb0-4bc0-85e6-5812d88238e1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: sal @ 2020-04-14 22:57 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 812 bytes --]

Hello everyone, I'm new to document formats and to Pandoc.

I have to migrate some documents from MediaWiki to Markdown.
I have installed the last version of Pandoc and did 

pandoc source -f mediawiki -t markdown -o outcome

but outcome does not look ok, tables are not converted.

I am attaching source and outcome files as an example.

Do you have any suggestion on how to troubleshoot?

Thank you!

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/79af9e1a-acb0-4bc0-85e6-5812d88238e1%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 1964 bytes --]

[-- Attachment #2: source --]
[-- Type: application/octet-stream, Size: 10317 bytes --]

Vyatta::Config (/opt/vyatta/share/perl5/Vyatta/Config.pm) is a Perl API library for working with VyOS configuration (and Vyatta and EdgeOS too). 

= Using the Library =
<pre>
use lib '/opt/vyatta/share/perl5';
use Vyatta::Config;
$config = new Vyatta::Config;
</pre>

= Definitions =
'''Active config''' is config, currently used by system.

'''Working config''' is config we are making during configuration session. 

== Effective config ==

The definition of "effective" is different under these two scenarios.

# When used outside a config session, "effective" == "active". In other words, in such cases the effective config is the same as the running config.
# When used during a config session, a config path (leading to either a "node" or a "value") is "effective" if ANY of the following is true. 
* active && working <br/> Path is in both active and working configs, i.e., unchanged.
*  !active && working && committed <br/>  Path is not in active, has been set in working, AND has already been committed, i.e., "commit" has successfully processed the addition/update of the path.
* active && !working && !committed <br/>  Path is in active, has been deleted from working, AND has not been committed yet, i.e., "commit" (per priority) has not processed the deletion of the path yet, or it has been processed but failed. 

'''Note:''' during commit, deactivate has the same effect as delete. So in such cases, as far as these functions are concerned, deactivated nodes don't exist.

= Method reference =

Currently API has the following methods:
{| class="wikitable"
|-
! Method
! Arguments
! Returns
! Purpose
|-
! colspan="4" | Low-level API functions that use the cstore library directly.
|-
| exists
| Configuration node
| True or false
| Returns true if specified node exists in current working config.
|-
| existsOrig
| Configuration node
| True or false
| Returns true if specified node exists in current active (running) config.
|-
| isDefault
| Configuration node
| True or false
| Returns true if specified node has default value in current working config.
|-
| isDefaultOrig
| Configuration node
| True or false
| Returns true if specified node had default value in current active (running) config.
|-
| listNodes
| Configuration path
| Array
| Returns array of all child nodes under specified path in working config.
|-
| listOrigNodes
| Configuration path
| Array
| Returns array of all child nodes under specified path in active config.
|-
| returnValue
| Configuration node
| Scalar
| Returns value of a node under specified path in working config.
|-
| returnOrigValue
| Configuration node
| Scalar
| Returns value of a node under specified path in active config.
|-
| returnValues
| Configuration multi-value node
| Array
| Returns array of all values of a multi-value node under specified path in working config.
|-
| returnOrigValues
| Configuration multi-value node
| Array 	
|Returns array of all values of a multi-value node under specified path in active config.
|-
! colspan="4" | Observers of the "effective" config
|-
| isEffective
| Configuration node
| True or false 
| Returns true if node under specified path is "effective".
|-
| isActive
| Configuration node
| True or false
| Same to isEffective.
|-
| listEffectiveNodes
| Configuration path
| Aray
| Returns array of "effective" child nodes during current commit under specified path.
|-
| listOrigPlusComNodes
| Configuration path
| Array
| Same to listEffectiveNodes.
|-
| returnEffectiveValue
| Configuration node
| Scalar
| Returns "effective" value of a node during current commit.
|-
| returnOrigPlusComValue
| Configuration node
| Scalar
| Returns "effective" value of a node during current commit.
|-
| returnEffectiveValues
| Configuraion multi-value node
| Array
| Returns array of "effective" values of a multi-value node during current commit.
|-
| returnOrigPlusComValues
| Configuraion multi-value node
| Array
| Returns array of "effective" values of a multi-value node during current commit.
|-
| isDeleted
| Configuration node
| True or false
| Returns true if node has been deleted in working config.
|-
| listDeleted
| Configuration path
| Array
| Returns array of nodes that have been deleted under specified level in working config.
|-
| returnDeletedValues
| Configuration multi-value node
| Array
| Returns array of values of a multi-value node that have been deleted in working config.
|-
| isAdded
| Configuration node
| True or false
| Returns true if specified node has been added in working config.
|-
| isChanged
| Configuration node
| True or false
| Returns true if specified node has been changed in working config.
|-
| listNodeStatus
| Configuration path
| Hash
| Return a hash of status of child nodes at specified level. Node name is the hash key. node status is the hash value. Node status can be one of 
"deleted", "added", "changed", or "static".
|-
| getTmplChildren
| Configuration path
| Array
| Return list of child nodes in the template hierarchy at specified level.
|-
| validateTmplPath
| Configuration path
| True or false
| Return whether specified path is a valid template path.
|-
| parseTmplAll
| Configuration path
| Hash
| Return hash ref of parsed template of specified path, undef if path is invalid. note: if !allow_val, path must terminate at a "node", not "value".
|-
| hasTmplChildren
| Configuration path
| True or false
| Returns true if specified configuration path has child nodes.
|-
! colspan="4" | "Deactivate-aware" observers of current working config or active config.
|-
| deactivated
| Configuration node
| True or false
| Return whether specified node is deactivated in working config. Note that this is different from "marked deactivated". If a node is "marked 
deactivated", then the node itself and any descendants are "deactivated".
|-
| deactivatedOrig
| Configuration node
| True or false 	
|Return whether specified node is deactivated in active config.
|-
| returnValuesDA
| Configuration multi-value node
| Array
| Deactivate aware version of returnValues().
|-
| returnOrigValuesDA
| Configuration multi-value node
| Array
| DA version of returnOrigValues().
|-
| returnValueDA
| Configuration node
| Scalar
| DA version of returnOrigValue().
|-
| listOrigNodesDA
| Configuration path
| Array
| DA version of listOrigNodes()
|-
| listNodeStatusDA
| Configuration path
| Hash
| DA version of listNodeStatus().
|-
| returnComment
| Configuration node
| Scalar
| Returns comment of "node" in working config or undef if comment doesn't exist.
|-
| returnOrigComment
| Configuration node
| Scalar
| Returns comment of "node" in active config or undef if comment doesn't exist
|-
! colspan="4" | High-level API functions (not using the cstore library directly)
|-
| setLevel
| Configuration path
| Current level
| Set the current level of config hierarchy to specified level (if defined).
|-
| returnParent
| Configuration node
| Scalar
| Returns the name of ancestor node relative to the current level. Each level up is represented by a ".." in the argument.
|-
| parseTmpl
| Configuration path
| Array
| Parse template of specified path and return ($is_multi, $is_text, $default) or undef if specified path is not valid.
|-
| isTagNode
| Configuration path
| True or false
| Returns true if specified path is a tag node.
|-
| isLeafNode
| Configuration node
| True or false
| Returns true if specified path is a "leaf node", i.e., single-/multi-value node.
|-
| isLeafValue
| Configuration node
| True or false
| Returns true if specified path is a "leaf value", i.e., value of a leaf node.
|-
| compareValueLists
| Original value list and new value list
| Lists of deleted and added nodes
| Compare two value lists and return "deleted" and "added" lists. Since this is for multi-value nodes, there is no "changed" (if a value's ordering changed, it is deleted then added).
|}

== Usage example ==
Background: Your helpdesk guys ask you to make a spreadsheet with remote-access PPTP VPN user information and keep it up to date. Of course you do not want to copy and paste this information by hand.

All spreadsheet software supports import from CSV, so the only thing we need to do is to extract values from config and print then as comma separated lines, passwords enclosed into double quotes for the case they contain a comma and add some header. Like this:
 user,password,address,is_disabled
 johnsmith,"this,isapass",192.0.2.41,no

Here we go:
<pre>
#!/usr/bin/perl

use strict;
# using the Vyatta perl API
use lib "/opt/vyatta/share/perl5/";
use Vyatta::Config;

# Settings
my $proto = "pptp";
my $delimiter = ",";
# CSV RFC4180 requires to use CRLF (\r\n) as line break
my $header = "user,password,address,disabled\r\n";

# Create a config instance
my $config = new Vyatta::Config;

# Set default config level, this allows to use relative paths
$config->setLevel("vpn pptp remote-access authentication local-users username");

# Obtain array of user names
my @users = $config->listNodes();

# Print file header
print $header;

# Now walk through the user names, obtain values and print them
foreach my $user (@users) {
    # Since we set config level to "vpn pptp remote-access authentication local-users username"
    # we now can specify only the remaining part as methods argument,
    # it will be appended to the path we used in setLevel()
    my $password = $config->returnValue("$user password");
    my $address = $config->returnValue("$user static-ip");
    #"disable" is a leaf node with no value, so we should check
    # if it exists instead of obtaining its value
    my $disabled = $config->exists("$user disable") ? "yes" : "no";

    # It's not prohibited to use "," in passwords,
    # so we should enclose them into quotes to prevent
    # the parser from treating them as delimiters
    $password = "\"$password\"";

    my $line = join($delimiter, $user, $password, $address, $disabled);
    print "$line\r\n";
}
</pre>

Check it works:
<pre>
vyatta@R1# show vpn pptp remote-access authentication local-users 
 username joerandomuser {
     disable
     password qwerrty
     static-ip 10.91.17.105
 }
 username johnsmith {
     password this,isapass
 }

vyatta@R1# perl ./pptpusers.pl 
user,password,address,disabled
joerandomuser,"qwerrty",10.91.17.105,yes
johnsmith,"this,isapass",,no
</pre>

[[Category: Development]]


[-- Attachment #3: outcome --]
[-- Type: application/octet-stream, Size: 15864 bytes --]

Vyatta::Config (/opt/vyatta/share/perl5/Vyatta/Config.pm) is a Perl API
library for working with VyOS configuration (and Vyatta and EdgeOS too).

Using the Library {#using_the_library}
=================

    use lib '/opt/vyatta/share/perl5';
    use Vyatta::Config;
    $config = new Vyatta::Config;

Definitions
===========

**Active config** is config, currently used by system.

**Working config** is config we are making during configuration session.

Effective config {#effective_config}
----------------

The definition of \"effective\" is different under these two scenarios.

1.  When used outside a config session, \"effective\" == \"active\". In
    other words, in such cases the effective config is the same as the
    running config.
2.  When used during a config session, a config path (leading to either
    a \"node\" or a \"value\") is \"effective\" if ANY of the following
    is true.

-   active && working\
    Path is in both active and working configs, i.e., unchanged.
-   !active && working && committed\
    Path is not in active, has been set in working, AND has already been
    committed, i.e., \"commit\" has successfully processed the
    addition/update of the path.
-   active && !working && !committed\
    Path is in active, has been deleted from working, AND has not been
    committed yet, i.e., \"commit\" (per priority) has not processed the
    deletion of the path yet, or it has been processed but failed.

**Note:** during commit, deactivate has the same effect as delete. So in
such cases, as far as these functions are concerned, deactivated nodes
don\'t exist.

Method reference {#method_reference}
================

Currently API has the following methods:

  Method                                                                       Arguments                                Returns                            Purpose
  ---------------------------------------------------------------------------- ---------------------------------------- ---------------------------------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  Low-level API functions that use the cstore library directly.                                                                                            
  exists                                                                       Configuration node                       True or false                      Returns true if specified node exists in current working config.
  existsOrig                                                                   Configuration node                       True or false                      Returns true if specified node exists in current active (running) config.
  isDefault                                                                    Configuration node                       True or false                      Returns true if specified node has default value in current working config.
  isDefaultOrig                                                                Configuration node                       True or false                      Returns true if specified node had default value in current active (running) config.
  listNodes                                                                    Configuration path                       Array                              Returns array of all child nodes under specified path in working config.
  listOrigNodes                                                                Configuration path                       Array                              Returns array of all child nodes under specified path in active config.
  returnValue                                                                  Configuration node                       Scalar                             Returns value of a node under specified path in working config.
  returnOrigValue                                                              Configuration node                       Scalar                             Returns value of a node under specified path in active config.
  returnValues                                                                 Configuration multi-value node           Array                              Returns array of all values of a multi-value node under specified path in working config.
  returnOrigValues                                                             Configuration multi-value node           Array                              Returns array of all values of a multi-value node under specified path in active config.
  Observers of the \"effective\" config                                                                                                                    
  isEffective                                                                  Configuration node                       True or false                      Returns true if node under specified path is \"effective\".
  isActive                                                                     Configuration node                       True or false                      Same to isEffective.
  listEffectiveNodes                                                           Configuration path                       Aray                               Returns array of \"effective\" child nodes during current commit under specified path.
  listOrigPlusComNodes                                                         Configuration path                       Array                              Same to listEffectiveNodes.
  returnEffectiveValue                                                         Configuration node                       Scalar                             Returns \"effective\" value of a node during current commit.
  returnOrigPlusComValue                                                       Configuration node                       Scalar                             Returns \"effective\" value of a node during current commit.
  returnEffectiveValues                                                        Configuraion multi-value node            Array                              Returns array of \"effective\" values of a multi-value node during current commit.
  returnOrigPlusComValues                                                      Configuraion multi-value node            Array                              Returns array of \"effective\" values of a multi-value node during current commit.
  isDeleted                                                                    Configuration node                       True or false                      Returns true if node has been deleted in working config.
  listDeleted                                                                  Configuration path                       Array                              Returns array of nodes that have been deleted under specified level in working config.
  returnDeletedValues                                                          Configuration multi-value node           Array                              Returns array of values of a multi-value node that have been deleted in working config.
  isAdded                                                                      Configuration node                       True or false                      Returns true if specified node has been added in working config.
  isChanged                                                                    Configuration node                       True or false                      Returns true if specified node has been changed in working config.
  listNodeStatus                                                               Configuration path                       Hash                               Return a hash of status of child nodes at specified level. Node name is the hash key. node status is the hash value. Node status can be one of \"deleted\", \"added\", \"changed\", or \"static\".
  getTmplChildren                                                              Configuration path                       Array                              Return list of child nodes in the template hierarchy at specified level.
  validateTmplPath                                                             Configuration path                       True or false                      Return whether specified path is a valid template path.
  parseTmplAll                                                                 Configuration path                       Hash                               Return hash ref of parsed template of specified path, undef if path is invalid. note: if !allow\_val, path must terminate at a \"node\", not \"value\".
  hasTmplChildren                                                              Configuration path                       True or false                      Returns true if specified configuration path has child nodes.
  \"Deactivate-aware\" observers of current working config or active config.                                                                               
  deactivated                                                                  Configuration node                       True or false                      Return whether specified node is deactivated in working config. Note that this is different from \"marked deactivated\". If a node is \"marked deactivated\", then the node itself and any descendants are \"deactivated\".
  deactivatedOrig                                                              Configuration node                       True or false                      Return whether specified node is deactivated in active config.
  returnValuesDA                                                               Configuration multi-value node           Array                              Deactivate aware version of returnValues().
  returnOrigValuesDA                                                           Configuration multi-value node           Array                              DA version of returnOrigValues().
  returnValueDA                                                                Configuration node                       Scalar                             DA version of returnOrigValue().
  listOrigNodesDA                                                              Configuration path                       Array                              DA version of listOrigNodes()
  listNodeStatusDA                                                             Configuration path                       Hash                               DA version of listNodeStatus().
  returnComment                                                                Configuration node                       Scalar                             Returns comment of \"node\" in working config or undef if comment doesn\'t exist.
  returnOrigComment                                                            Configuration node                       Scalar                             Returns comment of \"node\" in active config or undef if comment doesn\'t exist
  High-level API functions (not using the cstore library directly)                                                                                         
  setLevel                                                                     Configuration path                       Current level                      Set the current level of config hierarchy to specified level (if defined).
  returnParent                                                                 Configuration node                       Scalar                             Returns the name of ancestor node relative to the current level. Each level up is represented by a \"..\" in the argument.
  parseTmpl                                                                    Configuration path                       Array                              Parse template of specified path and return (\$is\_multi, \$is\_text, \$default) or undef if specified path is not valid.
  isTagNode                                                                    Configuration path                       True or false                      Returns true if specified path is a tag node.
  isLeafNode                                                                   Configuration node                       True or false                      Returns true if specified path is a \"leaf node\", i.e., single-/multi-value node.
  isLeafValue                                                                  Configuration node                       True or false                      Returns true if specified path is a \"leaf value\", i.e., value of a leaf node.
  compareValueLists                                                            Original value list and new value list   Lists of deleted and added nodes   Compare two value lists and return \"deleted\" and \"added\" lists. Since this is for multi-value nodes, there is no \"changed\" (if a value\'s ordering changed, it is deleted then added).

Usage example {#usage_example}
-------------

Background: Your helpdesk guys ask you to make a spreadsheet with
remote-access PPTP VPN user information and keep it up to date. Of
course you do not want to copy and paste this information by hand.

All spreadsheet software supports import from CSV, so the only thing we
need to do is to extract values from config and print then as comma
separated lines, passwords enclosed into double quotes for the case they
contain a comma and add some header. Like this:

`user,password,address,is_disabled`\
`johnsmith,"this,isapass",192.0.2.41,no`

Here we go:

    #!/usr/bin/perl

    use strict;
    # using the Vyatta perl API
    use lib "/opt/vyatta/share/perl5/";
    use Vyatta::Config;

    # Settings
    my $proto = "pptp";
    my $delimiter = ",";
    # CSV RFC4180 requires to use CRLF (\r\n) as line break
    my $header = "user,password,address,disabled\r\n";

    # Create a config instance
    my $config = new Vyatta::Config;

    # Set default config level, this allows to use relative paths
    $config->setLevel("vpn pptp remote-access authentication local-users username");

    # Obtain array of user names
    my @users = $config->listNodes();

    # Print file header
    print $header;

    # Now walk through the user names, obtain values and print them
    foreach my $user (@users) {
        # Since we set config level to "vpn pptp remote-access authentication local-users username"
        # we now can specify only the remaining part as methods argument,
        # it will be appended to the path we used in setLevel()
        my $password = $config->returnValue("$user password");
        my $address = $config->returnValue("$user static-ip");
        #"disable" is a leaf node with no value, so we should check
        # if it exists instead of obtaining its value
        my $disabled = $config->exists("$user disable") ? "yes" : "no";

        # It's not prohibited to use "," in passwords,
        # so we should enclose them into quotes to prevent
        # the parser from treating them as delimiters
        $password = "\"$password\"";

        my $line = join($delimiter, $user, $password, $address, $disabled);
        print "$line\r\n";
    }

Check it works:

    vyatta@R1# show vpn pptp remote-access authentication local-users 
     username joerandomuser {
         disable
         password qwerrty
         static-ip 10.91.17.105
     }
     username johnsmith {
         password this,isapass
     }

    vyatta@R1# perl ./pptpusers.pl 
    user,password,address,disabled
    joerandomuser,"qwerrty",10.91.17.105,yes
    johnsmith,"this,isapass",,no

[Category: Development](Category:_Development "wikilink")

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MediaWiki to Markdown conversion
       [not found] ` <79af9e1a-acb0-4bc0-85e6-5812d88238e1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-04-15  0:03   ` Daniel Staal
       [not found]     ` <8499788f-514a-9723-148e-f079effe88db-Jdbf3xiKgS8@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Staal @ 2020-04-15  0:03 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

On 4/14/20 6:57 PM, sal wrote:
> Hello everyone, I'm new to document formats and to Pandoc.
> 
> I have to migrate some documents from MediaWiki to Markdown.
> I have installed the last version of Pandoc and did
> 
> |
> pandoc source -f mediawiki -t markdown -o outcome
> |
> 
> but outcome does not look ok, tables are not converted.
> 
> I am attaching source and outcome files as an example.
> 
> Do you have any suggestion on how to troubleshoot?

The table looks fine to me.  It's in Simple Tables format, one of 
several that Pandoc's markdown supports.  If you want to use a different 
one, the easiest way is typically to disable that particular table 
extension:

```
pandoc source -f mediawiki -t markdown-simple_tables -o outcome
```

I'm not sure off the top of my head what type of table will be generated 
then, as there are still several.  ;)

Daniel T. Staal

-- 
---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MediaWiki to Markdown conversion
       [not found]     ` <8499788f-514a-9723-148e-f079effe88db-Jdbf3xiKgS8@public.gmane.org>
@ 2020-04-15 11:42       ` sal
       [not found]         ` <41ad78f7-a660-40ec-b49a-7061b2800b7f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: sal @ 2020-04-15 11:42 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1405 bytes --]


Hey, thank you Daniel for your answer!



> The table looks fine to me.


So, do you see the outcome table ok?
Maybe I'm doing wrong more than just one thing...
What did you use to see it?
I go to an online markdown viewer (like https://markdownlivepreview.com/ or 
any other),
I paste the outcome there and see the table is not properly converted.

 

> It's in Simple Tables format, one of 
> several that Pandoc's markdown supports.  If you want to use a different 
> one, the easiest way is typically to disable that particular table 
> extension: 
>
> ``` 
> pandoc source -f mediawiki -t markdown-simple_tables -o outcome 
> ``` 
>

I tested that command, but again no success with the table.
If there are different ways to convert tables, is that documented somewhere?

Thanks again. Once I get this thing done, I still will have to convert it 
to "remarkup",
which is used by Phabricator software.
Unfortunately I have not find any tool to convert directly from MediaWiki 
to ReMarkUp.

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/41ad78f7-a660-40ec-b49a-7061b2800b7f%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2248 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MediaWiki to Markdown conversion
       [not found]         ` <41ad78f7-a660-40ec-b49a-7061b2800b7f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-04-15 15:32           ` Daniel Staal
       [not found]             ` <673beeae-bdca-10b0-9a4e-acbe9d082975-Jdbf3xiKgS8@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: Daniel Staal @ 2020-04-15 15:32 UTC (permalink / raw)
  To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw

On 4/15/20 7:42 AM, sal wrote:
> So, do you see the outcome table ok?
> Maybe I'm doing wrong more than just one thing...
> What did you use to see it?
> I go to an online markdown viewer (like https://markdownlivepreview.com/ 
> or any other),
> I paste the outcome there and see the table is not properly converted.

I open it up as a text file.  No viewer used.  ;)

There's no 'official' table spec in Markdown, just whatever table each 
variant has supported, so if you're using a viewer (or a different 
converter) you need to match the variant that viewer supports.

> I tested that command, but again no success with the table.
> If there are different ways to convert tables, is that documented somewhere?

<https://pandoc.org/MANUAL.html#tables>

> Thanks again. Once I get this thing done, I still will have to convert 
> it to "remarkup",
> which is used by Phabricator software.
> Unfortunately I have not find any tool to convert directly from 
> MediaWiki to ReMarkUp.

Looks like remarkup uses what Pandoc calls 'Pipe Tables', so you may want:

```
pandoc source -f mediawiki -t 
markdown-simple_tables+pipe_tables-multiline_tables -o outcome
```

Daniel T. Staal

-- 
---------------------------------------------------------------
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---------------------------------------------------------------


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MediaWiki to Markdown conversion
       [not found]             ` <673beeae-bdca-10b0-9a4e-acbe9d082975-Jdbf3xiKgS8@public.gmane.org>
@ 2020-04-15 20:19               ` sal
       [not found]                 ` <07c2c373-5f47-4283-b740-d15feabd8ba5-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: sal @ 2020-04-15 20:19 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 872 bytes --]



>
> Looks like remarkup uses what Pandoc calls 'Pipe Tables', so you may want: 
>
> ``` 
> pandoc source -f mediawiki -t 
> markdown-simple_tables+pipe_tables-multiline_tables -o outcome 
> ``` 
>
>
Hey! It worked! Well, not perfectly, but I can manually edit some little 
details (many "\" signs to be deleted and some missing merged cells in the 
table).

I used this command you suggested and I could open it directly with 
remarkup.

Thank you very much!!

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/07c2c373-5f47-4283-b740-d15feabd8ba5%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 1427 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MediaWiki to Markdown conversion
       [not found]                 ` <07c2c373-5f47-4283-b740-d15feabd8ba5-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-04-19 23:10                   ` sal
       [not found]                     ` <4dbf4d89-1367-44fd-8227-5a39cee018b9-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: sal @ 2020-04-19 23:10 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1008 bytes --]

Hi again,

I'm having again problems with tables when migrating other documents from 
MediaWiki to RemarkUp (or just trying to normal Markdown).
I have tried different combinations from 
https://pandoc.org/MANUAL.html#tables without success, I don't get a (more 
or less) correct table.

Now, when using
pandoc source -f mediawiki -t markdown-simple_tables+pipe_tables-multiline_tables 
-o outcome
the original table gets splitted into many different tables.

Please find attached the source file used and the outcome file I get.

Again, any suggestion on what to do is very welcome...

Thank you!

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/4dbf4d89-1367-44fd-8227-5a39cee018b9%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2513 bytes --]

[-- Attachment #2: source --]
[-- Type: application/octet-stream, Size: 10212 bytes --]

Since release 6.2 (Mendocino) Vyatta has an API for working with configuration from shell scripts. Its binary is '''/opt/vyatta/sbin/my_cli_shell_api''' and has symbolic link at '''/bin/cli-shell-api'''. This page describes methods of the API 
as of Vyatta 6.4 (Oxnard) release.

For a less technical tutorial, see [[Shell script tutorial]] page.

= Definitions =
'''Active config''' is config, currently used by system.

'''Working config''' is config we are making during configuration session. 

== Effective config ==

The definition of "effective" is different under these two scenarios.

# When used outside a config session, "effective" == "active". In other words, in such cases the effective config is the same as the running config.
# When used during a config session, a config path (leading to either a "node" or a "value") is "effective" if ANY of the following is true. 
* active && working <br/> Path is in both active and working configs, i.e., unchanged.
*  !active && working && committed <br/>  Path is not in active, has been set in working, AND has already been committed, i.e., "commit" has successfully processed the addition/update of the path.
* active && !working && !committed <br/>  Path is in active, has been deleted from working, AND has not been committed yet, i.e., "commit" (per priority) has not processed the deletion of the path yet, or it has been processed but failed. 

'''Note:''' during commit, deactivate has the same effect as delete. So in such cases, as far as these functions are concerned, deactivated nodes don't exist.

= Method reference =
It is invoked in format:

 cli-shell-api <method> <configuration path>

Currently API has the following methods:
{|class="wikitable"
|-
! Method
! Arguments
! Purpose
|-
| getSessionEnv 
| Session identifier 
| Returns environment variables needed for configuration session to work<ref>This and all other methods that return environment variables return a string suitable for "eval".</ref>
|-
| getEditEnv 
| Configuration path 
| Returns environment variables for edit level specified in argument. 
|-
| getEditUpEnv 
| None
| Returns environment variables for edit level above current edit level. Returns string "Already at the top level" when ran at the top edit level. 
|-
| getEditResetEnv 
| None
| Returns environment variables for the top level. 
|-
| editLevelAtRoot 
| None
| Returns 0 if current edit level is top level, 1 otherwise 
|-
| getCompletionEnv 
| Command and component (e.g. "set service" or "edit firewall") 
| Returns environment variables needed for command completion to work. 
|-
| getEditLevelStr 
| None
| Returns current edit level. 
|-
| markSessionUnsaved
| None
| Mark current configuration session unsaved.
|-
|unmarkSessionUnsaved
| None
| Reset session unsaved flag.
|-
| sessionUnsaved
| None
| Returns 0 when session unsaved flag is set, 1 otherwise.
|-
| setupSession
| None
| Initiate a configuration session. Needs environment to be set properly, see getSessionEnv.
|-
| sessionChanged
| None
| Returns 0 if configuration was changed from current session, 1 otherwise.
|-
| teardownSession
| None
| End current configuration session.
|-
| inSession 
| None
| Returns 0 if configuration session is set up, 1 otheriwise.
|-
| exists
| Configuration path
| Returns 0 if specified configuration path exists (either in currently used or built during the session config), 1 otherwise.
|-
| existsActive
| Configuration path
| Returns 0 if specified node exists in the current active (running) configuration, 1 otherwise.
|-
| existsEffective
| Configuration path
| Returns 0 if specified path exists in effective config, 1 otherwise
|-
| isMulti
| Configuration path
| Returns 0 if specified node is a multi node (i.e. may have more than one value), 1 otherwise
|-
| isTag
| Configuration path
| Returns 0 if specified node is a tag node, 1 otherwise
|-
| Configuration path
| ???
|-
| isLeaf
| Configuration path
| Returns 0 if specified node is a leaf node, 1 otherwise
|-
| getNodeType
| Configuration path
| Returns on of the following: '''value''' for value nodes, '''leaf''' for leaf nodes, '''multi''' for multi nodes, '''tag''' for tag nodes, '''non-leaf''' for the rest.
|-
| listNodes
| Configuration path
| Returns list of nodes under specified configuration path<ref>This and other listNodes* methods return strings that must be eval'ed into an array (e.g. values=$(cli-shell-api listNodes interfaces); eval "nodes=($values)" )</ref>.
|-
| listActiveNodes
| Configuration path
| Returns list of nodes under specified configuration path that are present in currently used config.
|-
| listEffectiveNodes
| Configuration path
| Returns list of effective nodes under specified configuration path that are present in effective config.
|-
| returnValue
| Configuration path
| Returns value of a node under specified configuration path.
|-
| returnActiveValue
| Configuration path
| Returns value of a node under specified configuration path as present in currently used config.
|-
| returnEffectiveValue
| Configuration path
| Returns effective value of a node under specified configuration path as present in currently used config.
|-
| returnValues
| Configuration path
| Returns values of a multinode under specified configuration path<ref>Output of this and all other returnValues* methods is a string that must be eval'ed.</ref>.
|-
| returnActiveValues
| Configuration path
| Returns values of a multinode under specified configuration path as present in currently used config.
|-
| returnEffectiveValues
| Configuration path
| Returns effective values of a multinode under specified configuration path as present in currently used config.
|-
| validateTmplPath
| Configuration path
| Validate the path regardless of given value (e.g. "interfaces ethernet" is a valid path whereas "interfaces foobar" is not.). Returns 0 if path is valid, 1 otherwise.
|-
| validateTmplValPath 
| Configuration path 
| Validate configuration path with respect to value (e.g. "interfaces ethernet" is a valid path, whereas "interfaces foo" is not). Returns 0 if path is valid, 1 otherwise.
|-
| validateTmplValPath
| Configuration path
| Validate configuration path with respect to value (e.g. "interfaces ethernet eth0" is a valid path, whereas "interfaces ethernet foo0" is not). Returns 0 if path is valid, 1 otherwise.
|-
| showCfg
| Configuration path (may be empty)
| Shows configuration under specified path.
|-
| showConfig
| Configuration path (may be empty)
| Show configuration under specified path. Supports the following options: <br> --show-active-only — show active configuration <br> --show-working-only — show working configuration <br> --show-show-defaults — include default value <br> --show-hide-secrets — replace private information like passwords with "*" <br> --show-context-diff — show "context diff" between two configs <br> --show-commands — show output in "commands" <br> --show-ignore-edit — don't use the edit level in environment <br> --show-cfg1 <cfg1> --show-cfg2 <cfg2> — specify the two configs to be diffed (must specify both), values may be file names, "@ACTIVE" or "@WORKING"
|-
| loadFile
| Path to config file
| Load configuration file
|-
| getPreCommitHookDir
| None
| Returns path to pre-commit hooks directory
|-
| getPostCommitHookDir
| None
| Returns path to post-commit hooks directory
|-
| cfExists
| Path to config file, configuration path
| Returns 0 if specified configuration path exists in specified config file
|-
| cfReturnValue
| Path to config file, configuration path
| Returns value of specified node in specified file
|-
| cfReturnValues
| Path to config file, configuration path
| Returns values under specified path in specified file
|}


= Usage =
== Setting up the session ==

Before changing configuration and using most part of cli-shell-api methods you must set up session. Current best practice is to use process identifier ($PPID) as session identifier.
<pre>
# Obtain session environment
session_env=$($SHELL_API getSessionEnv $PPID)

# Evaluate environment string
eval $session_env

# Setup the session
cli-shell-api setupSession
</pre>
Then you can make sure session is set up:
<pre>
 cli-shell-api inSession
 if [ $? -ne 0 ]; then
   echo "Something went wrong!"
 fi
</pre>

Don't forget to finish your session using cli-shell-api teardownSession.
In a bash script make sure session is finished using something like:
<pre>
function atexit() {
    cli-shell-api teardownSession
}
trap atexit EXIT
</pre>

== Configuration output ==

You can do configuration output even if session is not set up. Example:
<pre>
# cli-shell-api showCfg firewall name TEST rule 10
   action reject
   source {
       address 172.16.0.0/24
   }
</pre>
== Working with multinode output ==

To work with output of listNodes, returnValues or similar methods you must eval it. Example:
<pre>
node_list=$(cli-shell-api listNodes firewall name TEST)
eval "NODES=($node_list)"

for i in "${NODES[@]}";
  do
    cli-shell-api showCfg firewall name TEST rule $i
  done
</pre>

== Modifying configuration ==

Warning: You must set up a session before modifying configuration.

cli-shell-api itself does not have methods to modify configuration. It is done with separate commands that are in /opt/vyatta/sbin (${vyatta_sbindir}) and have names same to configuration mode commands with "my_" prefix. The only exception is command for saving configuration, which is /opt/vyatta/vyatta-save-config.pl (accepts config file name as its optional argument).

You may use the following snippet:
<pre>
SET=${vyatta_sbindir}/my_set

DELETE=${vyatta_sbindir}/my_delete

COPY=${vyatta_sbindir}/my_copy

MOVE=${vyatta_sbindir}/my_move

RENAME=${vyatta_sbindir}/my_rename

ACTIVATE=${vyatta_sbindir}/my_activate

DEACTIVATE=${vyatta_sbindir}/my_activate

COMMENT=${vyatta_sbindir}/my_comment

COMMIT=${vyatta_sbindir}/my_commit

DISCARD=${vyatta_sbindir}/my_discard

SAVE=${vyatta_sbindir}/vyatta-save-config.pl
</pre>
Example:
<pre>
$SET interfaces ethernet eth0 address 10.0.0.1/24
$COMMIT
</pre>

== Script examples  ==
* [[Search for nodes containing some string]].

= References =
<references />

{{Lowercase title}}
[[Category: Development]]


[-- Attachment #3: outcome --]
[-- Type: application/octet-stream, Size: 26148 bytes --]

Since release 6.2 (Mendocino) Vyatta has an API for working with
configuration from shell scripts. Its binary is
**/opt/vyatta/sbin/my\_cli\_shell\_api** and has symbolic link at
**/bin/cli-shell-api**. This page describes methods of the API as of
Vyatta 6.4 (Oxnard) release.

For a less technical tutorial, see [Shell script
tutorial](Shell_script_tutorial "wikilink") page.

Definitions
===========

**Active config** is config, currently used by system.

**Working config** is config we are making during configuration session.

Effective config {#effective_config}
----------------

The definition of \"effective\" is different under these two scenarios.

1.  When used outside a config session, \"effective\" == \"active\". In
    other words, in such cases the effective config is the same as the
    running config.
2.  When used during a config session, a config path (leading to either
    a \"node\" or a \"value\") is \"effective\" if ANY of the following
    is true.

-   active && working\
    Path is in both active and working configs, i.e., unchanged.
-   !active && working && committed\
    Path is not in active, has been set in working, AND has already been
    committed, i.e., \"commit\" has successfully processed the
    addition/update of the path.
-   active && !working && !committed\
    Path is in active, has been deleted from working, AND has not been
    committed yet, i.e., \"commit\" (per priority) has not processed the
    deletion of the path yet, or it has been processed but failed.

**Note:** during commit, deactivate has the same effect as delete. So in
such cases, as far as these functions are concerned, deactivated nodes
don\'t exist.

Method reference {#method_reference}
================

It is invoked in format:

`cli-shell-api ``<method>`{=html}` ``<configuration path>`{=html}

Currently API has the following methods:

+----------------------+----------------------+----------------------+
| Method               | Arguments            | Purpose              |
+======================+======================+======================+
| getSessionEnv        | Session identifier   | Returns environment  |
|                      |                      | variables needed for |
|                      |                      | configuration        |
|                      |                      | session to work[^4]  |
+----------------------+----------------------+----------------------+
| getEditEnv           | Configuration path   | Returns environment  |
|                      |                      | variables for edit   |
|                      |                      | level specified in   |
|                      |                      | argument.            |
+----------------------+----------------------+----------------------+
| getEditUpEnv         | None                 | Returns environment  |
|                      |                      | variables for edit   |
|                      |                      | level above current  |
|                      |                      | edit level. Returns  |
|                      |                      | string \"Already at  |
|                      |                      | the top level\" when |
|                      |                      | ran at the top edit  |
|                      |                      | level.               |
+----------------------+----------------------+----------------------+
| getEditResetEnv      | None                 | Returns environment  |
|                      |                      | variables for the    |
|                      |                      | top level.           |
+----------------------+----------------------+----------------------+
| editLevelAtRoot      | None                 | Returns 0 if current |
|                      |                      | edit level is top    |
|                      |                      | level, 1 otherwise   |
+----------------------+----------------------+----------------------+
| getCompletionEnv     | Command and          | Returns environment  |
|                      | component (e.g.      | variables needed for |
|                      | \"set service\" or   | command completion   |
|                      | \"edit firewall\")   | to work.             |
+----------------------+----------------------+----------------------+
| getEditLevelStr      | None                 | Returns current edit |
|                      |                      | level.               |
+----------------------+----------------------+----------------------+
| markSessionUnsaved   | None                 | Mark current         |
|                      |                      | configuration        |
|                      |                      | session unsaved.     |
+----------------------+----------------------+----------------------+
| unmarkSessionUnsaved | None                 | Reset session        |
|                      |                      | unsaved flag.        |
+----------------------+----------------------+----------------------+
| sessionUnsaved       | None                 | Returns 0 when       |
|                      |                      | session unsaved flag |
|                      |                      | is set, 1 otherwise. |
+----------------------+----------------------+----------------------+
| setupSession         | None                 | Initiate a           |
|                      |                      | configuration        |
|                      |                      | session. Needs       |
|                      |                      | environment to be    |
|                      |                      | set properly, see    |
|                      |                      | getSessionEnv.       |
+----------------------+----------------------+----------------------+
| sessionChanged       | None                 | Returns 0 if         |
|                      |                      | configuration was    |
|                      |                      | changed from current |
|                      |                      | session, 1           |
|                      |                      | otherwise.           |
+----------------------+----------------------+----------------------+
| teardownSession      | None                 | End current          |
|                      |                      | configuration        |
|                      |                      | session.             |
+----------------------+----------------------+----------------------+
| inSession            | None                 | Returns 0 if         |
|                      |                      | configuration        |
|                      |                      | session is set up, 1 |
|                      |                      | otheriwise.          |
+----------------------+----------------------+----------------------+
| exists               | Configuration path   | Returns 0 if         |
|                      |                      | specified            |
|                      |                      | configuration path   |
|                      |                      | exists (either in    |
|                      |                      | currently used or    |
|                      |                      | built during the     |
|                      |                      | session config), 1   |
|                      |                      | otherwise.           |
+----------------------+----------------------+----------------------+
| existsActive         | Configuration path   | Returns 0 if         |
|                      |                      | specified node       |
|                      |                      | exists in the        |
|                      |                      | current active       |
|                      |                      | (running)            |
|                      |                      | configuration, 1     |
|                      |                      | otherwise.           |
+----------------------+----------------------+----------------------+
| existsEffective      | Configuration path   | Returns 0 if         |
|                      |                      | specified path       |
|                      |                      | exists in effective  |
|                      |                      | config, 1 otherwise  |
+----------------------+----------------------+----------------------+
| isMulti              | Configuration path   | Returns 0 if         |
|                      |                      | specified node is a  |
|                      |                      | multi node (i.e. may |
|                      |                      | have more than one   |
|                      |                      | value), 1 otherwise  |
+----------------------+----------------------+----------------------+
| isTag                | Configuration path   | Returns 0 if         |
|                      |                      | specified node is a  |
|                      |                      | tag node, 1          |
|                      |                      | otherwise            |
+----------------------+----------------------+----------------------+
| Configuration path   | ???                  |                      |
+----------------------+----------------------+----------------------+
| isLeaf               | Configuration path   | Returns 0 if         |
|                      |                      | specified node is a  |
|                      |                      | leaf node, 1         |
|                      |                      | otherwise            |
+----------------------+----------------------+----------------------+
| getNodeType          | Configuration path   | Returns on of the    |
|                      |                      | following: **value** |
|                      |                      | for value nodes,     |
|                      |                      | **leaf** for leaf    |
|                      |                      | nodes, **multi** for |
|                      |                      | multi nodes, **tag** |
|                      |                      | for tag nodes,       |
|                      |                      | **non-leaf** for the |
|                      |                      | rest.                |
+----------------------+----------------------+----------------------+
| listNodes            | Configuration path   | Returns list of      |
|                      |                      | nodes under          |
|                      |                      | specified            |
|                      |                      | configuration        |
|                      |                      | path[^5].            |
+----------------------+----------------------+----------------------+
| listActiveNodes      | Configuration path   | Returns list of      |
|                      |                      | nodes under          |
|                      |                      | specified            |
|                      |                      | configuration path   |
|                      |                      | that are present in  |
|                      |                      | currently used       |
|                      |                      | config.              |
+----------------------+----------------------+----------------------+
| listEffectiveNodes   | Configuration path   | Returns list of      |
|                      |                      | effective nodes      |
|                      |                      | under specified      |
|                      |                      | configuration path   |
|                      |                      | that are present in  |
|                      |                      | effective config.    |
+----------------------+----------------------+----------------------+
| returnValue          | Configuration path   | Returns value of a   |
|                      |                      | node under specified |
|                      |                      | configuration path.  |
+----------------------+----------------------+----------------------+
| returnActiveValue    | Configuration path   | Returns value of a   |
|                      |                      | node under specified |
|                      |                      | configuration path   |
|                      |                      | as present in        |
|                      |                      | currently used       |
|                      |                      | config.              |
+----------------------+----------------------+----------------------+
| returnEffectiveValue | Configuration path   | Returns effective    |
|                      |                      | value of a node      |
|                      |                      | under specified      |
|                      |                      | configuration path   |
|                      |                      | as present in        |
|                      |                      | currently used       |
|                      |                      | config.              |
+----------------------+----------------------+----------------------+
| returnValues         | Configuration path   | Returns values of a  |
|                      |                      | multinode under      |
|                      |                      | specified            |
|                      |                      | configuration        |
|                      |                      | path[^6].            |
+----------------------+----------------------+----------------------+
| returnActiveValues   | Configuration path   | Returns values of a  |
|                      |                      | multinode under      |
|                      |                      | specified            |
|                      |                      | configuration path   |
|                      |                      | as present in        |
|                      |                      | currently used       |
|                      |                      | config.              |
+----------------------+----------------------+----------------------+
| r                    | Configuration path   | Returns effective    |
| eturnEffectiveValues |                      | values of a          |
|                      |                      | multinode under      |
|                      |                      | specified            |
|                      |                      | configuration path   |
|                      |                      | as present in        |
|                      |                      | currently used       |
|                      |                      | config.              |
+----------------------+----------------------+----------------------+
| validateTmplPath     | Configuration path   | Validate the path    |
|                      |                      | regardless of given  |
|                      |                      | value (e.g.          |
|                      |                      | \"interfaces         |
|                      |                      | ethernet\" is a      |
|                      |                      | valid path whereas   |
|                      |                      | \"interfaces         |
|                      |                      | foobar\" is not.).   |
|                      |                      | Returns 0 if path is |
|                      |                      | valid, 1 otherwise.  |
+----------------------+----------------------+----------------------+
| validateTmplValPath  | Configuration path   | Validate             |
|                      |                      | configuration path   |
|                      |                      | with respect to      |
|                      |                      | value (e.g.          |
|                      |                      | \"interfaces         |
|                      |                      | ethernet\" is a      |
|                      |                      | valid path, whereas  |
|                      |                      | \"interfaces foo\"   |
|                      |                      | is not). Returns 0   |
|                      |                      | if path is valid, 1  |
|                      |                      | otherwise.           |
+----------------------+----------------------+----------------------+
| validateTmplValPath  | Configuration path   | Validate             |
|                      |                      | configuration path   |
|                      |                      | with respect to      |
|                      |                      | value (e.g.          |
|                      |                      | \"interfaces         |
|                      |                      | ethernet eth0\" is a |
|                      |                      | valid path, whereas  |
|                      |                      | \"interfaces         |
|                      |                      | ethernet foo0\" is   |
|                      |                      | not). Returns 0 if   |
|                      |                      | path is valid, 1     |
|                      |                      | otherwise.           |
+----------------------+----------------------+----------------------+
| showCfg              | Configuration path   | Shows configuration  |
|                      | (may be empty)       | under specified      |
|                      |                      | path.                |
+----------------------+----------------------+----------------------+
| showConfig           | Configuration path   | Show configuration   |
|                      | (may be empty)       | under specified      |
|                      |                      | path. Supports the   |
|                      |                      | following options:\  |
|                      |                      | \--show-active-only  |
|                      |                      | --- show active      |
|                      |                      | configuration\       |
|                      |                      | \--show-working-only |
|                      |                      | --- show working     |
|                      |                      | configuration\       |
|                      |                      | \                    |
|                      |                      | --show-show-defaults |
|                      |                      | --- include default  |
|                      |                      | value\               |
|                      |                      | \--show-hide-secrets |
|                      |                      | --- replace private  |
|                      |                      | information like     |
|                      |                      | passwords with       |
|                      |                      | \"\*\"\              |
|                      |                      | \--show-context-diff |
|                      |                      | --- show \"context   |
|                      |                      | diff\" between two   |
|                      |                      | configs\             |
|                      |                      | \--show-commands --- |
|                      |                      | show output in       |
|                      |                      | \"commands\"\        |
|                      |                      | \--show-ignore-edit  |
|                      |                      | --- don\'t use the   |
|                      |                      | edit level in        |
|                      |                      | environment\         |
|                      |                      | \--show-cfg1         |
|                      |                      | `<cfg1>`{=html}      |
|                      |                      | \--show-cfg2         |
|                      |                      | `<cfg2>`{=html} ---  |
|                      |                      | specify the two      |
|                      |                      | configs to be diffed |
|                      |                      | (must specify both), |
|                      |                      | values may be file   |
|                      |                      | names, \"\@ACTIVE\"  |
|                      |                      | or \"\@WORKING\"     |
+----------------------+----------------------+----------------------+
| loadFile             | Path to config file  | Load configuration   |
|                      |                      | file                 |
+----------------------+----------------------+----------------------+
| getPreCommitHookDir  | None                 | Returns path to      |
|                      |                      | pre-commit hooks     |
|                      |                      | directory            |
+----------------------+----------------------+----------------------+
| getPostCommitHookDir | None                 | Returns path to      |
|                      |                      | post-commit hooks    |
|                      |                      | directory            |
+----------------------+----------------------+----------------------+
| cfExists             | Path to config file, | Returns 0 if         |
|                      | configuration path   | specified            |
|                      |                      | configuration path   |
|                      |                      | exists in specified  |
|                      |                      | config file          |
+----------------------+----------------------+----------------------+
| cfReturnValue        | Path to config file, | Returns value of     |
|                      | configuration path   | specified node in    |
|                      |                      | specified file       |
+----------------------+----------------------+----------------------+
| cfReturnValues       | Path to config file, | Returns values under |
|                      | configuration path   | specified path in    |
|                      |                      | specified file       |
+----------------------+----------------------+----------------------+

Usage
=====

Setting up the session {#setting_up_the_session}
----------------------

Before changing configuration and using most part of cli-shell-api
methods you must set up session. Current best practice is to use process
identifier (\$PPID) as session identifier.

    # Obtain session environment
    session_env=$($SHELL_API getSessionEnv $PPID)

    # Evaluate environment string
    eval $session_env

    # Setup the session
    cli-shell-api setupSession

Then you can make sure session is set up:

     cli-shell-api inSession
     if [ $? -ne 0 ]; then
       echo "Something went wrong!"
     fi

Don\'t forget to finish your session using cli-shell-api
teardownSession. In a bash script make sure session is finished using
something like:

    function atexit() {
        cli-shell-api teardownSession
    }
    trap atexit EXIT

Configuration output {#configuration_output}
--------------------

You can do configuration output even if session is not set up. Example:

    # cli-shell-api showCfg firewall name TEST rule 10
       action reject
       source {
           address 172.16.0.0/24
       }

Working with multinode output {#working_with_multinode_output}
-----------------------------

To work with output of listNodes, returnValues or similar methods you
must eval it. Example:

    node_list=$(cli-shell-api listNodes firewall name TEST)
    eval "NODES=($node_list)"

    for i in "${NODES[@]}";
      do
        cli-shell-api showCfg firewall name TEST rule $i
      done

Modifying configuration {#modifying_configuration}
-----------------------

Warning: You must set up a session before modifying configuration.

cli-shell-api itself does not have methods to modify configuration. It
is done with separate commands that are in /opt/vyatta/sbin
(\${vyatta\_sbindir}) and have names same to configuration mode commands
with \"my\_\" prefix. The only exception is command for saving
configuration, which is /opt/vyatta/vyatta-save-config.pl (accepts
config file name as its optional argument).

You may use the following snippet:

    SET=${vyatta_sbindir}/my_set

    DELETE=${vyatta_sbindir}/my_delete

    COPY=${vyatta_sbindir}/my_copy

    MOVE=${vyatta_sbindir}/my_move

    RENAME=${vyatta_sbindir}/my_rename

    ACTIVATE=${vyatta_sbindir}/my_activate

    DEACTIVATE=${vyatta_sbindir}/my_activate

    COMMENT=${vyatta_sbindir}/my_comment

    COMMIT=${vyatta_sbindir}/my_commit

    DISCARD=${vyatta_sbindir}/my_discard

    SAVE=${vyatta_sbindir}/vyatta-save-config.pl

Example:

    $SET interfaces ethernet eth0 address 10.0.0.1/24
    $COMMIT

Script examples {#script_examples}
---------------

-   [Search for nodes containing some
    string](Search_for_nodes_containing_some_string "wikilink").

References
==========

```{=html}
<references />
```
```{=mediawiki}
{{Lowercase title}}
```
[Category: Development](Category:_Development "wikilink")

[^1]: This and all other methods that return environment variables
    return a string suitable for \"eval\".

[^2]: This and other listNodes\* methods return strings that must be
    eval\'ed into an array (e.g. values=\$(cli-shell-api listNodes
    interfaces); eval \"nodes=(\$values)\" )

[^3]: Output of this and all other returnValues\* methods is a string
    that must be eval\'ed.

[^4]: This and all other methods that return environment variables
    return a string suitable for \"eval\".

[^5]: This and other listNodes\* methods return strings that must be
    eval\'ed into an array (e.g. values=\$(cli-shell-api listNodes
    interfaces); eval \"nodes=(\$values)\" )

[^6]: Output of this and all other returnValues\* methods is a string
    that must be eval\'ed.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MediaWiki to Markdown conversion
       [not found]                     ` <4dbf4d89-1367-44fd-8227-5a39cee018b9-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-04-20  0:31                       ` John MacFarlane
       [not found]                         ` <m2wo6bf15k.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: John MacFarlane @ 2020-04-20  0:31 UTC (permalink / raw)
  To: sal, pandoc-discuss


It's not split into many different tables.
It's one table in pandoc's "grid table" format.

Why wasn't a "pipe table" used?  Because this table contains
content that can't be represented in a pipe table:  possibly
the raw HTML hard line breaks (<br>) in the cell with all the
options.


sal <s.lorente-2HksPz9409E@public.gmane.org> writes:

> Hi again,
>
> I'm having again problems with tables when migrating other documents from 
> MediaWiki to RemarkUp (or just trying to normal Markdown).
> I have tried different combinations from 
> https://pandoc.org/MANUAL.html#tables without success, I don't get a (more 
> or less) correct table.
>
> Now, when using
> pandoc source -f mediawiki -t markdown-simple_tables+pipe_tables-multiline_tables 
> -o outcome
> the original table gets splitted into many different tables.
>
> Please find attached the source file used and the outcome file I get.
>
> Again, any suggestion on what to do is very welcome...
>
> Thank you!
>
> -- 
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/4dbf4d89-1367-44fd-8227-5a39cee018b9%40googlegroups.com.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MediaWiki to Markdown conversion
       [not found]                         ` <m2wo6bf15k.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
@ 2020-04-20 23:41                           ` sal
       [not found]                             ` <6026cf94-1b7a-4e0a-9b0b-790891b6e759-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 9+ messages in thread
From: sal @ 2020-04-20 23:41 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 2128 bytes --]

Thank you John.

I'm not sure I understand.
Is it possible to get that table somehow converted in such a case?
Is there anything I could do?


On Monday, April 20, 2020 at 2:31:53 AM UTC+2, John MacFarlane wrote:
>
>
> It's not split into many different tables. 
> It's one table in pandoc's "grid table" format. 
>
> Why wasn't a "pipe table" used?  Because this table contains 
> content that can't be represented in a pipe table:  possibly 
> the raw HTML hard line breaks (<br>) in the cell with all the 
> options. 
>
>
> sal <s.lo...-2HksPz9409E@public.gmane.org <javascript:>> writes: 
>
> > Hi again, 
> > 
> > I'm having again problems with tables when migrating other documents 
> from 
> > MediaWiki to RemarkUp (or just trying to normal Markdown). 
> > I have tried different combinations from 
> > https://pandoc.org/MANUAL.html#tables without success, I don't get a 
> (more 
> > or less) correct table. 
> > 
> > Now, when using 
> > pandoc source -f mediawiki -t 
> markdown-simple_tables+pipe_tables-multiline_tables 
> > -o outcome 
> > the original table gets splitted into many different tables. 
> > 
> > Please find attached the source file used and the outcome file I get. 
> > 
> > Again, any suggestion on what to do is very welcome... 
> > 
> > Thank you! 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "pandoc-discuss" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
> > To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pandoc-discuss/4dbf4d89-1367-44fd-8227-5a39cee018b9%40googlegroups.com. 
>
>

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6026cf94-1b7a-4e0a-9b0b-790891b6e759%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 4159 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: MediaWiki to Markdown conversion
       [not found]                             ` <6026cf94-1b7a-4e0a-9b0b-790891b6e759-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-04-21  5:43                               ` John MacFarlane
  0 siblings, 0 replies; 9+ messages in thread
From: John MacFarlane @ 2020-04-21  5:43 UTC (permalink / raw)
  To: sal, pandoc-discuss


Take a look at the pandoc user's manual to see the different
table formats supported by pandoc's markdown.

Markdown pipe tables assume content that fits on one line in each
cell.  In your document the <br> is parsed as a LineBreak, which
makes the content unable to fit in a pipe table cell.  (A
Markdown line break  involves a newline.)

So your document can't be rendered as a pipe table.  It can
be rendered as a grid table, which is what you're getting.
If you're using pandoc to convert the result, this should be
fine.  If you want it to work e.g. on GitHub, that won't work;
you need either a pipe table (which won't work for your source)
or fall back to HTML (which is what pandoc will do if you disable
grid tables).


sal <s.lorente-2HksPz9409E@public.gmane.org> writes:

> Thank you John.
>
> I'm not sure I understand.
> Is it possible to get that table somehow converted in such a case?
> Is there anything I could do?
>
>
> On Monday, April 20, 2020 at 2:31:53 AM UTC+2, John MacFarlane wrote:
>>
>>
>> It's not split into many different tables. 
>> It's one table in pandoc's "grid table" format. 
>>
>> Why wasn't a "pipe table" used?  Because this table contains 
>> content that can't be represented in a pipe table:  possibly 
>> the raw HTML hard line breaks (<br>) in the cell with all the 
>> options. 
>>
>>
>> sal <s.lo...-2HksPz9409E@public.gmane.org <javascript:>> writes: 
>>
>> > Hi again, 
>> > 
>> > I'm having again problems with tables when migrating other documents 
>> from 
>> > MediaWiki to RemarkUp (or just trying to normal Markdown). 
>> > I have tried different combinations from 
>> > https://pandoc.org/MANUAL.html#tables without success, I don't get a 
>> (more 
>> > or less) correct table. 
>> > 
>> > Now, when using 
>> > pandoc source -f mediawiki -t 
>> markdown-simple_tables+pipe_tables-multiline_tables 
>> > -o outcome 
>> > the original table gets splitted into many different tables. 
>> > 
>> > Please find attached the source file used and the outcome file I get. 
>> > 
>> > Again, any suggestion on what to do is very welcome... 
>> > 
>> > Thank you! 
>> > 
>> > -- 
>> > You received this message because you are subscribed to the Google 
>> Groups "pandoc-discuss" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. 
>> > To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/pandoc-discuss/4dbf4d89-1367-44fd-8227-5a39cee018b9%40googlegroups.com. 
>>
>>
>
> -- 
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6026cf94-1b7a-4e0a-9b0b-790891b6e759%40googlegroups.com.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-04-21  5:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-14 22:57 MediaWiki to Markdown conversion sal
     [not found] ` <79af9e1a-acb0-4bc0-85e6-5812d88238e1-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-04-15  0:03   ` Daniel Staal
     [not found]     ` <8499788f-514a-9723-148e-f079effe88db-Jdbf3xiKgS8@public.gmane.org>
2020-04-15 11:42       ` sal
     [not found]         ` <41ad78f7-a660-40ec-b49a-7061b2800b7f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-04-15 15:32           ` Daniel Staal
     [not found]             ` <673beeae-bdca-10b0-9a4e-acbe9d082975-Jdbf3xiKgS8@public.gmane.org>
2020-04-15 20:19               ` sal
     [not found]                 ` <07c2c373-5f47-4283-b740-d15feabd8ba5-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-04-19 23:10                   ` sal
     [not found]                     ` <4dbf4d89-1367-44fd-8227-5a39cee018b9-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-04-20  0:31                       ` John MacFarlane
     [not found]                         ` <m2wo6bf15k.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>
2020-04-20 23:41                           ` sal
     [not found]                             ` <6026cf94-1b7a-4e0a-9b0b-790891b6e759-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-04-21  5:43                               ` John MacFarlane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).