Skip to content

Commit 767a219

Browse files
committed
Changed some comments and reviewed the code.
1 parent 2d7a9c2 commit 767a219

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

Attributes/HtmlAttribute.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace CodeTranslator.Attributes
88
{
99
/// <summary>
10-
/// Represents a base class for the different attribute types.
10+
/// Represents a class for an html attribute.
1111
/// </summary>
1212
public class HtmlAttribute
1313
{
@@ -56,11 +56,6 @@ public override bool Equals(object obj)
5656

5757
public override int GetHashCode()
5858
{
59-
//here I use the Name only, because:
60-
//if we have two pairs of options:
61-
//A(x)-B and A-B, where A(x) means only the option 'x' from attribute A and just A means the whole attribute value,
62-
//we won't know which of them to use. We will have to add additional options, which I don't need right now.
63-
//I need to use the value here!
6459
return Name.GetHashCode() ^ (Value != null ? Value.GetHashCode() : -1);
6560
}
6661

Nodes/SyntaxNode.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public abstract class SyntaxNode
1313
/// <summary>
1414
/// The string which is used to replace the newline.
1515
/// </summary>
16-
public string NewlineRepresentation { get; set; } //the set has to be public in order to be able to use it in derived classes
16+
public string NewlineRepresentation { get; set; }
1717
/// <summary>
1818
/// The list of the children nodes.
1919
/// </summary>

Parsers/BBCodeParser.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public string ToHtml(string bbcode)
3737
/// <param name="code">The bbcode</param>
3838
protected override SyntaxNode ParseSyntaxNode(string code)
3939
{
40-
//don't forget to take care for those tags where we don't want to parse the tags!!!
4140
if (string.IsNullOrEmpty(code)) throw new ArgumentNullException("code");
4241
Stack<SyntaxNode> syntaxStack = new Stack<SyntaxNode>(); //this is a stack that will hold the bbcode nodes.
4342
syntaxStack.Push(new BBCodeSyntaxNode(null, null)); //push the main node.

Tags/HtmlTag.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace CodeTranslator.Tags
1414
public class HtmlTag : Tag
1515
{
1616
/// <summary>
17-
/// The string which is used to replace the new line in Html. It gets converted to /n in BBCode
17+
/// The string which is used to replace the new line in Html. It gets converted to \n in BBCode
1818
/// </summary>
1919
public string NewlineReplacer { get; private set; }
2020
/// <summary>
@@ -36,19 +36,20 @@ public HtmlTag(string openHtmlTag, string closeHtmlTag, string newlineReplacer,
3636
/// <param name="tagOptions">The different possible options</param>
3737
protected override void ValidateOptions(TagOption[] tagOptions)
3838
{
39-
if (tagOptions.Distinct().Count() != tagOptions.Length) throw new ArgumentException("All option values must be different!");
39+
if (tagOptions.Distinct().Count() != tagOptions.Length) throw new ArgumentException("All option values must be unique!");
4040
if (tagOptions.FirstOrDefault(o => !(o is HtmlOption)) != null) throw new ArgumentException("All option values must be of type HtmlOption!");
4141
}
4242

4343
/// <summary>
44-
/// Returns true if the value written in the parameter is a valid tag. The results is produced for the whole tag.
44+
/// Returns true if the value written in the parameter is a valid tag. The result is produced for the whole tag.
4545
/// </summary>
4646
/// <param name="tagValue">The tag value</param>
4747
public override bool IsValid(string tagValue)
4848
{
4949
if (string.IsNullOrEmpty(tagValue)) throw new ArgumentNullException("tagValue");
5050
tagValue = tagValue.Trim('<', '>'); //trim the open and close brackets
51-
string tagName = tagValue.Contains(' ') ? tagValue.Substring(0, tagValue.IndexOf(' ')) : tagValue;//get the tag name (until the first space character or the whole string.)
51+
//get the tag name (until the first space character if attributes are present or the whole string.)
52+
string tagName = tagValue.Contains(' ') ? tagValue.Substring(0, tagValue.IndexOf(' ')) : tagValue;
5253
if (OpenTag != tagName)
5354
{
5455
if (CloseTag == tagName) return true; //the close tag is always valid

Tags/Tag.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,9 @@ public Tag(string openTag, string closeTag, params TagOption[] tagOptions)
5050
/// </summary>
5151
/// <param name="tagValue">The tag value</param>
5252
public abstract bool IsValid(string tagValue);
53+
/// <summary>
54+
/// Returns the opposite representation - HTML for BBCode and vice versa.
55+
/// </summary>
56+
public abstract string ToOppositeRepresentation();
5357
}
5458
}

0 commit comments

Comments
 (0)