-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create OSCALMarkdownProse Component #536
Conversation
This will add a basic implementation of a possible OSCALMarkdownProse component.
In order to get markdown to display at a basic level throughout the application, this seems like a decent start. @kylelaker & @brian-easyd I know there was some discussion outside the issue on what we want here. Is there anything that you'd think we would want to add for an initial implementation of dealing with markdown? |
Great start! I think initially we want a test just to make sure that this does what we expect; so: <OSCALMarkdownProse>*Hello*, **world**</OSCALMarkdownProse> Should look like: Hello, world And that const text = "<script>alert('Nasty script!')</script>"
<OSCALMarkdownProse children={text}/> Doesn't do anything gross. In fact, I almost wonder if we should just pass |
This is first test to see if there markdown can be converted by matching it with its corresponding HTML Currently this test is failing due to a JEST configuration error between JS and TS. What would be the best way to resolve this? I've looked online and it changes the JEST configurations however I don't want to make any unecessary changes to the dependencies
We found this and tried the suggestions that were mentioned but couldn't get it working: https://stackoverflow.com/questions/49263429/jest-gives-an-error-syntaxerror-unexpected-token-export |
I want to make sure everyone is aware of NIST's official description for exactly what should be handled by Markup-line and Markup-multiline: Ultimately our capabilities should do exactly this. No more. No less. For now I am OK with achieving a reasonable sub-set and expanding in a later sprint if this proves too big an effort for one sprint. Also, as I mentioned yesterday, the stored data format must be markdown, but that does not automatically mean the editor must be markdown. Ideally the user interface is friendly to security practitioners who are not likely to know markdown, yet can also accept markdown for those who know it. Again, for now I'm good with one or the other (non-markdown friendly or markdown-friendly), provided any solution we select allows us to grow on top of the work we do now rather than having to replace it. |
Hmm so that looks like another case of markdown with extensions since tables are supported. But then the single-line version has a more limited set... That'll take more time to actually fine-tune. And we have to decide if we want different behavior for viewing vs editing. We probably also need to our best to display whatever is there, even if it's not technically totally valid (someone put a table in a markup-line) but we shouldn't let a user write something like that.
We should be able to accomplish this by only using this new Component when viewing/displaying the text and not try to perform any translation of Markdown to HTML (for now).
I'd like to handle this in a separate ticket (can we create one)? This will require finding/adding/integrating a WYSIWYG editor of some sort or using something like the text field editor here on GitHub. That will be a much larger lift.
Hopefully we get that by starting to add a custom component (as we're doing here) that's very minimal and then adding more features over time. This was why I advocated for this approach rather than just using the |
This adds a brief description of the OSCALMarkdownProse component and adds a configuration in package.json so that the component tests will be able to run
Made tests to see if the component can convert string literals to to its equivalent in HTML So far there are tests for - plaintext - Bold, Italics, Plaintext mixed, - Hyperlinks - Images
…mics/oscal-react-library into feature/handle-markdown
Currently the tests check whether something in markdown will convert to its HTML equivalent. |
can we fix the linting? |
@@ -0,0 +1,40 @@ | |||
import React from "react"; | |||
import { OSCALMarkdownProse } from "./OSCALMarkdownProse"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { OSCALMarkdownProse } from "./OSCALMarkdownProse"; | |
import OSCALMarkdownProse from "./OSCALMarkdownProse"; |
Right now the component tests are failing and I believe if you remove the brackets around OSCALMarkdownProse
it will prevent them from failing
import ReactDomServer from "react-dom/server"; | ||
import OSCALMarkdownProse from "./OSCALMarkdownProse"; | ||
|
||
export default function asHtml(input) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be exported? What happens if we don't do that?
Note: line does not allow multiple lines so not sure if this is what multiline markdown should be. I am unable to get embedded HTML tags like <h1> body <h2> header 2 </h2> more text </h1> I've also tried markdown with mutiple lines sich as `const multiline string = "line 1 \ line 2 \ line 3\"` and converting that to HTML and caused linting errors
const multilineMarkdown = | ||
"this should b here # h1 Heading 8- ## h2 Heading This is in heading 2 ### h3 Heading This is in heading 3 #### h4 Heading ##### **h5 Heading** ###### h6 Heading "; | ||
const multilineAsHTML = | ||
"<p>this should b here # h1 Heading 8- ## h2 Heading This is in heading 2 ### h3 Heading This is in heading 3 #### h4 Heading ##### <strong>h5 Heading</strong> ###### h6 Heading</p>"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So uhh despite being called "multiline" this is just one line.
const multilineMarkdown = | |
"this should b here # h1 Heading 8- ## h2 Heading This is in heading 2 ### h3 Heading This is in heading 3 #### h4 Heading ##### **h5 Heading** ###### h6 Heading "; | |
const multilineAsHTML = | |
"<p>this should b here # h1 Heading 8- ## h2 Heading This is in heading 2 ### h3 Heading This is in heading 3 #### h4 Heading ##### <strong>h5 Heading</strong> ###### h6 Heading</p>"; | |
const multilineMarkdown = ` | |
this should be here | |
# h1 heading | |
## h2 Heading | |
This is in heading 2 | |
### h3 Heading | |
This is in heading 3 | |
##### **h5 Heading** | |
`; | |
const multilineHtml = "<p>this should be here</p><h1>h1 heading</h1><h2>h2 Heading</h2><p>This is in heading 2</p><h3>h3 Heading</h3><p>This is in heading 3 </p><h5><strong>h5 Heading</strong></h5>"; |
ya know +/- some formatting and spacing and all that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy with this as a base component with simple tests to start the integration work with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a solid start to handle markdown throughout the application consistently. I also like seeing were creating our tests at the beginning of this issue. Great work!
@kylelaker @brian-easyd Demo of Issue #536 for acceptance https://easydynamics-my.sharepoint.com/:v:/p/niqbal/EVohd_Csn51OnQ09gFAH2osB65GDEKvCnjOI69rnAWNQ9A?e=ysfjUo |
I agree this is complete |
This will add a basic implementation of an OSCALMarkdownProse
component. Once the component has been implemented as desired, it will
be used to handle markdown in prose statements, metadata titles,
system implementation remarks, and control implementation descriptions.
Currently it is a draft and any suggestions are greatly appreciated.
Part of #156.