Skip to content

Commit

Permalink
Revert "Merge pull request #27 from anusii/zy/26_multiline_comment"
Browse files Browse the repository at this point in the history
This reverts commit b1c6a8b, reversing
changes made to de9df94.
  • Loading branch information
zheyxu committed Nov 27, 2023
1 parent 529f6e7 commit 33c0f8a
Showing 1 changed file with 1 addition and 29 deletions.
30 changes: 1 addition & 29 deletions lib/src/graph.dart
Original file line number Diff line number Diff line change
Expand Up @@ -568,11 +568,8 @@ class Graph {
///
/// Updates [Graph.ctx], [Graph.groups] and [Graph.triples] in the process.
void parseTurtle(String fileContent) {
String processedContent = _preprocessTurtleContent(fileContent);
final String content = _removeComments(processedContent);

final String content = _removeComments(fileContent);
List parsedList = parser.parse(content).value;

for (List tripleList in parsedList) {
_saveToContext(tripleList);
}
Expand Down Expand Up @@ -925,29 +922,4 @@ class Graph {
}
return rtnStr;
}

/// Preprocesses Turtle content to handle multiline string literals.
///
/// This function addresses the issue of multiline literals in Turtle syntax,
/// which are enclosed within triple quotes `"""`.
String _preprocessTurtleContent(String turtleContent) {
// Regular expression to match multiline literals.

final multilineLiteralRegex = RegExp(r'"""(.*?)"""', dotAll: true);

// Replace each multiline literal with a processed version.

return turtleContent.replaceAllMapped(multilineLiteralRegex, (match) {
// Get the multiline literal, excluding the triple quotes.

String multilineLiteral = match.group(1)!;

// Process the multiline literal as needed.
// Example: Replace line breaks with a special sequence.
String processedLiteral = multilineLiteral.replaceAll('\n', '\\n');

// Return the processed literal with the original triple quotes
return '"$processedLiteral"';
});
}
}

0 comments on commit 33c0f8a

Please sign in to comment.