Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

ParserParameterProcessor to support JSON typed annotation #1891

Merged
merged 1 commit into from Oct 5, 2016

Conversation

mwjames
Copy link
Contributor

@mwjames mwjames commented Oct 5, 2016

This PR is made in reference to: #N/A

This PR addresses or contains:

  • This allows to add JSON typed annotation in the #set and #subobject parser function using the @json marker.
  • Using the JSON format allows for creating structured annotation by means of electronic generators
  • A depth of 3+ is not supported (for details see test cases)
{{#set:
    |@json={
    "foo": [
         "bar",
         "foobar"
    ]
}
}}

This PR includes:

  • Tests (unit/integration)
  • CI build passed

This allows to add JSON typed annotation in the #set and #subobject
parser function using the `@json` marker.

```
{{#set:
    |@JSON={
    "foo": [
         "bar",
         "foobar"
    ]
}
}}

```
@mwjames mwjames added the enhancement Alters an existing functionality or behaviour label Oct 5, 2016
@mwjames mwjames added this to the SMW 2.5 milestone Oct 5, 2016
@mwjames
Copy link
Contributor Author

mwjames commented Oct 5, 2016

@mwjames
Copy link
Contributor Author

mwjames commented Oct 5, 2016

@kghbln FYI

@mwjames
Copy link
Contributor Author

mwjames commented Oct 5, 2016

Using the | pipe symbol generally posses an issue within a parser function when used as part of the content representation and to avoid breaking the content +pipe can be used to signal that no breakage is expected for the preceding element (well, internally we clue the content together since the MW parser would split the content no matter what).

{{#set:
    |@json={
    "has text": "Some text with a | pipe symbol ..."
}|+pipe }}

{{#subobject:
    |@json={
    "has text": "Some text with a | pipe symbol ..."
}|+pipe }}

Just to clarify on how +pipe works, MW's parser would produce something like:

array(4) {
  [0]=>
  string(0) ""
  [1]=>
  string(41) "@json={
    "has text": "Some text with a"
  [2]=>
  string(25) "pipe symbol ..."
}"
  [3]=>
  string(5) "+pipe"
}

Since +pipe indicates the usage of | and knowing the convention by means of MediaWiki, we can concatenate the string without the split yet with one exception that we don't know whether the text before and after | contained trailing spaces or not (MW's parser removes spaces). The processed text will appear as Some text with a|pipe symbol within ... instead of the Some text with a | pipe symbol within ...

PS: I did forget to add them to the integration test, so it would be nice if someone could extend the test.

@mwjames mwjames merged commit 7c5d7b9 into master Oct 5, 2016
@mwjames mwjames deleted the json-param branch October 5, 2016 20:57
@kghbln kghbln added the wikidocu missing Code changes (mostly features) what have not yet been documented label Oct 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Alters an existing functionality or behaviour wikidocu missing Code changes (mostly features) what have not yet been documented
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants