From: sal <s.lorente-2HksPz9409E@public.gmane.org>
To: pandoc-discuss <pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: MediaWiki to Markdown conversion
Date: Tue, 14 Apr 2020 15:57:14 -0700 (PDT) [thread overview]
Message-ID: <79af9e1a-acb0-4bc0-85e6-5812d88238e1@googlegroups.com> (raw)
[-- 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")
next reply other threads:[~2020-04-14 22:57 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-14 22:57 sal [this message]
[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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=79af9e1a-acb0-4bc0-85e6-5812d88238e1@googlegroups.com \
--to=s.lorente-2hkspz9409e@public.gmane.org \
--cc=pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).