Workflow for formatting extracted references

Hi @asmecher,

the regex was now capturing even standalone DOI identifiers in the citation and also some name abbreviations of authors.

citation_regex

I’ve changed the quantifier for the https group from ? to + and now it seems to be working fine.

The code for the whole function.

function getCitationWithLinks() {
		$citation = $this->getRawCitation();
		if (stripos($citation, '<a href=') === false) {
			return preg_replace_callback(
				'|((https?:\/\/)+([\d\w\.-]+\.[\w\.]{2,6})[^\s\]\[\<\>]*\/?)|i',
				function($matches) {
					$trailingDot = substr($matches[1], -1) == '.';
					$url = rtrim($matches[1], '.');
					return "<a href=\"$url\">$url</a>" . ($trailingDot?'.':'');
				},
				$citation
			);
		}
		return $citation;
	}

Sorry, I don’t know how to put colours in the code. :expressionless:

Best regards,

Domek