Open xXxTheDarkprogramerxXx opened 2 years ago
public string DictionaryToString(IDictionary<string, object> dictionary)
{
string dictionaryString = "";
foreach (KeyValuePair<string, object> keyValues in dictionary)
{
string val = "";
if (keyValues.Key.ToString() == "class")
{
//could have been done a lot cleaner but this should work for now to make a class be rendered correctly
val = keyValues.Value.ToString().Replace("[", "").Replace("]", "").Replace(@"""", "").Replace(",","").Replace("\n", "").Replace("\r", "").Trim();
}
else
{
val = keyValues.Value.ToString();
}
dictionaryString += keyValues.Key + "=\"" + val + "\" ";
}
return dictionaryString;
}
/// <summary>
/// Elements that should not be closed by default
/// </summary>
public List<string> DoNotCloseTags = new List<string>() { "link", "meta" , "img","br" };
/// <summary>
/// Self closing tags
/// </summary>
public List<string> SelfClosingTags = new List<string>() { "img" };
/// <summary>
/// Get Sub Ite,s
/// </summary>
/// <param name="node">Main node then sub node to n(th)</param>
/// <param name="tabin">idea was to do tabbing</param>
/// <returns></returns>
public string GetSubItems(Jsonize.Abstractions.Models.JsonizeNode node,int tabin =0)
{
string tab = "";
for (int i = 0; i < tabin; i++)
{
tab += "\t";
}
tabin++;
string rtnstr = "";
if (node.NodeType != "Document")
{
if (node.NodeType == "DocumentType")
{
rtnstr += tab+ "<!DOCTYPE " + node.Tag + ">\n";
}
if (node.NodeType == "Element")
{
rtnstr += tab + "<" + node.Tag + " " + DictionaryToString(node.Attr) + " >\n";
}
if(node.NodeType == "Comment")
{
rtnstr += tab + "<!-- ";
}
}
for (int i = 0; i < node.Children.Count(); i++)
{
rtnstr += GetSubItems(node.Children.ElementAt(i));
}
if (!string.IsNullOrEmpty(node.Text))
{
rtnstr += node.Text;
}
//remember to close the tag
if (node.NodeType == "Element")
{
if (!DoNotCloseTags.Contains(node.Tag))
{
rtnstr += "</" + node.Tag + ">\n";
}
}
if(node.NodeType == "Comment")
{
rtnstr += " -->\n";
}
return rtnstr;
}
/// <summary>
/// Quickly create an HTML render
/// </summary>
/// <param name="node"></param>
/// <returns></returns>
public string CreateHtmlPage(Jsonize.Abstractions.Models.JsonizeNode node)
{
string Page = "";
Page = GetSubItems(node);
return Page ;
}
Looks like an interesting idea, could you prepare this as a PR? I have some feedback that's easier to give that way.
Ideally we would actually leverage AngleSharp again to build a DOM there that can be serialised into HTML.
Also, what's the motivation for this feature? Are you using this package for something?
Also, what's the motivation for this feature? Are you using this package for something?
Actually wanted to use it for an open source tool for the PS4/PS5 scene was thinking of having it for a tool that allows a user to customize their own exploit host or something like that
Also was thinking of doing this in another peace of software somewhere but for now thinking of the ps scene stuff
Looks like an interesting idea, could you prepare this as a PR? I have some feedback that's easier to give that way.
Ideally we would actually leverage AngleSharp again to build a DOM there that can be serialised into HTML.
That would be ideal I agree just haven't worked with AngleSharp yet so will have to look into it
The potential for this is actually to create a full fledge usable CRM with a great editor ext
Just brainstorming right now
Cool, sounds fun, let me know how you get on, or what you come up with :)
How did you get on with this @xXxTheDarkprogramerxXx, did you find something you want to use it for?
Hi @JackWFinlay sorry for late response been crazy busy here
Currently im using the basic app version to dump data from https://psxdatacenter.com/
To get data info per game form psx emulation on the ps4
Have not yet done anything else for creating a page as of yet but still have an idea for a customizable host
Add the ability to convert the json created back to an html string