Vitaliy-1 / JATSParser

JATSParser is aimed to be integrated with Open Journal Systems 3.0+ for transforming JATS XML to various formats
GNU General Public License v3.0
11 stars 20 forks source link

Line breaks #15

Closed eddoff closed 4 years ago

eddoff commented 4 years ago

Line breaks such as <br> or (in XML) <break> in the XML body text are stripped off. Can you please add such tags?

Best regards

Edvin

Vitaliy-1 commented 4 years ago

Hi @eddoff,

Why do you need line breaks? Where do you use them?

eddoff commented 4 years ago

Some part of the article text was a citation of a poetry or song. And there I want to decide where to put the line breaks. For example check this article: http://www.venue.ep.liu.se/article.html?DOI=10.3384/venue.2001-788X.13218 if I use

the spacing will be too large.

eddoff commented 4 years ago

Is it also possible to allow to use CDTA-tags?

Vitaliy-1 commented 4 years ago

Nope, CDATA isn't implemented. Maybe, you would like to make a PR for line breaks?

eddoff commented 4 years ago

I tried to make a change in JATSParser/src/JATSParser/HTML/Text.php as you might have seen in my first post in this thread (which I later edited since I realized it did not work).

Vitaliy-1 commented 4 years ago

You were on the right path. You modified JATS Parser's HTML output (only case "break":...); the change should be also reflected in the class that is responsible for parsing JATS: https://github.com/Vitaliy-1/JATSParser/blob/master/src/JATSParser/Body/Text.php#L21; I think just pointing that the code should control also element with the name break by adding it to the referenced array should be enough.

eddoff commented 4 years ago

I tried, but it did not work. Could it be any problem since the the tag is written with only one tag: (i.e. no starting and ending tag). Do I need to have "break/" in the code then instead?

Vitaliy-1 commented 4 years ago

I'm reading the latest version of NISO JATS publishing set standards and it's said there that use of break tag is discouraged. Moreover, if it'll be used in the way we are planning - JATS XML wouldn't be valid. Take a look: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/break.html By the link, you can find the answer on how to mark poems - it's verse-group tag. It's something that I can add, what do you think?

eddoff commented 4 years ago

Yep, please add <verse-group>, <verse-line> and <attrib> then.

eddoff commented 4 years ago

Thank you for this

However there seems to be problems. Here is Fatal error from the log: [Tue Jan 21 11:18:37.638314 2020] [php7:error] [pid 22476] [client xxx:2669] PHP Fatal error: Uncaught TypeError: Return value of JATSParser\\Body\\Verse::getContent() must be of the type array, null returned in /var/www/html/journal/plugins/themes/oldGregg/JATSParser/src/JATSParser/Body/Verse.php:25\nStack trace:\n#0 /var/www/html/journal/plugins/themes/oldGregg/JATSParser/src/JATSParser/HTML/Verse.php(13): JATSParser\\Body\\Verse->getContent()\n#1 /var/www/html/journal/plugins/themes/oldGregg/JATSParser/src/JATSParser/HTML/Document.php(168): JATSParser\\HTML\\Verse->setContent(Object(JATSParser\\Body\\Verse))\n#2 /var/www/html/journal/plugins/themes/oldGregg/JATSParser/src/JATSParser/HTML/Document.php(16): JATSParser\\HTML\\Document->extractContent(Array)\n#3 /var/www/html/journal/plugins/themes/oldGregg/OldGreggThemePlugin.inc.php(323): JATSParser\\HTML\\Document->__construct(Object(JATSParser\\Body\\Document))\n#4 /var/www/html/journal/plugins/themes/oldGregg/OldGreggThemePlugin.inc.php(191): OldGreggThemePlugin->htmlCreation(Object(TemplateManager), Object(JATSParser\\Body\\Document), Object(ArticleGalley))\n#5 /var/ww in /var/www/html/journal/plugins/themes/oldGregg/JATSParser/src/JATSParser/Body/Verse.php on line 25

Vitaliy-1 commented 4 years ago

Do you have verse-lines's inside verse-group? Like here: https://jats.nlm.nih.gov/publishing/tag-library/1.2/element/verse-line.html

eddoff commented 4 years ago

Great! Thank you! Now it works!

Is it also possible to add a class to the p-element so that it is possible to change the layout with CSS? For example:

Vitaliy-1 commented 4 years ago

As far as I can see from NISO JATS guidelines, the closest by meaning attribute for this is type, like list-type for lists, sec-type for sections and content-type for most repeated elements. It's something that I can add and is partially implemented, e.g. for lists.

Vitaliy-1 commented 4 years ago

@eddoff , can you open a new issue for this, as this one is resolved?