Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
17cbc0a
Create test2
lin-ash Apr 15, 2022
7ee66a8
Update MarkdownParse.java
lin-ash Apr 15, 2022
e835b4d
Create test-file2.md
lin-ash Apr 15, 2022
4af74bf
Merge branch 'main' of https://github.com/ehsly/markdown-parser
lin-ash Apr 15, 2022
0c286d9
Delete test2
lin-ash Apr 15, 2022
cd5a725
Update MarkdownParse.java
lin-ash Apr 15, 2022
766a98d
Merge branch 'main' of https://github.com/ehsly/markdown-parser
lin-ash Apr 15, 2022
1f8aaa2
index error
lin-ash Apr 15, 2022
6327201
returns a message if no link is found
lin-ash Apr 15, 2022
f4e991b
test-file4.md infinite loop (fixed)
lin-ash Apr 22, 2022
4df50ae
junit files
lin-ash Apr 22, 2022
af79bcd
junit test
lin-ash Apr 22, 2022
e97a5fe
Create lib
lin-ash Apr 22, 2022
c7fc310
Delete lib
lin-ash Apr 22, 2022
9b57f9c
update
lin-ash Apr 22, 2022
36676ee
Delete README.md
lin-ash Apr 22, 2022
7fc2926
update
lin-ash Apr 22, 2022
0a5e6ac
Delete MarkdownParse
lin-ash Apr 22, 2022
744cebf
Create folder.md
lin-ash Apr 22, 2022
f2bad1c
Add files via upload
lin-ash Apr 22, 2022
0fdfb70
Delete folder.md
lin-ash Apr 22, 2022
d7f9b8c
Merge branch 'main' of https://github.com/ehsly/markdown-parser
lin-ash Apr 22, 2022
592ef5c
junit tests
lin-ash Apr 22, 2022
bafc2bf
extra test cases
lin-ash Apr 22, 2022
fce29b6
Update MarkdownParseTest.java
lin-ash Apr 22, 2022
84870fc
Update MarkdownParse.java
lin-ash Apr 22, 2022
fd7b2e3
Update MarkdownParseTest.java
lin-ash Apr 22, 2022
683f134
Update MarkdownParseTest.java
lin-ash Apr 22, 2022
96ba02d
Delete lab-test-file2.md
lin-ash Apr 22, 2022
b7641e8
Delete lab-test-file3.md
lin-ash Apr 22, 2022
c8cbb7a
Delete lab-test-file4.md
lin-ash Apr 22, 2022
89f0848
Delete lab-test-file6.md
lin-ash Apr 22, 2022
0465ac3
Delete lab-test-file8.md
lin-ash Apr 22, 2022
e6c8fe8
Delete lab-test-file7.md
lin-ash Apr 22, 2022
869d506
Delete lab-testfile5.md
lin-ash Apr 22, 2022
4f1a40c
Create main.yml
lin-ash Apr 29, 2022
f826e68
Update main.yml
lin-ash Apr 29, 2022
9b446e4
Merge branch 'main' of https://github.com/ehsly/markdown-parser
lin-ash Apr 29, 2022
edbcfe6
wrong output
lin-ash Apr 29, 2022
75c07c0
fix link format test case
lin-ash Apr 29, 2022
bc81b44
makefile to test markdownParse
lin-ash May 6, 2022
9edb389
Update main.yml
lin-ash May 6, 2022
acc70ed
Update main.yml
lin-ash May 6, 2022
d3343f4
Update makefile
lin-ash May 6, 2022
dd8170f
Create mdparse
lin-ash May 6, 2022
cdf7618
delete later
May 8, 2022
4ae9745
Update MarkdownParse.java
lin-ash May 8, 2022
cd90e1a
Merge branch 'main' of https://github.com/ehsly/markdown-parser
lin-ash May 8, 2022
1374305
adding a line
May 8, 2022
b3348a3
Merge branch 'main' of github.com:ehsly/markdown-parser
May 10, 2022
13abefe
Delete cs15lsp22auv@ieng6.ucsd.edu
lin-ash May 10, 2022
de8171a
Delete file_to_change
lin-ash May 10, 2022
ce0cc93
update
lin-ash May 20, 2022
22a5353
Merge branch 'main' of https://github.com/ehsly/markdown-parser
lin-ash May 20, 2022
ddaecb3
Update main.yml
lin-ash May 20, 2022
a53e641
test cases for lab report 4
lin-ash May 23, 2022
a55990f
Merge branch 'main' of https://github.com/ehsly/markdown-parser
lin-ash May 23, 2022
dd35ecf
System.out.print("test"
May 23, 2022
51db0e2
Update MarkdownParse.java
lin-ash May 23, 2022
15651d0
Update MarkdownParseTest.java
lin-ash May 23, 2022
d79090b
Merge branch 'main' of github.com:ehsly/markdown-parser
May 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ main ]
pull_request:
branches: [ main ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

# Runs a single command using the runners shell
- name: Runs makefile on MarkdownParse
run: make test

# Runs a set of commands using the runners shell
- name: Run a multi-line script
run: |

5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"java.project.referencedLibraries": [
"lib/**/*.jar"
]
}
12 changes: 10 additions & 2 deletions MarkdownParse.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,22 @@ public static ArrayList<String> getLinks(String markdown) {
int closeBracket = markdown.indexOf("]", openBracket);
int openParen = markdown.indexOf("(", closeBracket);
int closeParen = markdown.indexOf(")", openParen);

if (openBracket == -1 || closeBracket == -1 ||
openParen == -1 || closeParen == -1) {
return toReturn;
}

if (closeBracket + 1 != openParen) {
return toReturn;
}

toReturn.add(markdown.substring(openParen + 1, closeParen));
currentIndex = closeParen + 1;
}

return toReturn;
}


public static void main(String[] args) throws IOException {
Path fileName = Path.of(args[0]);
String content = Files.readString(fileName);
Expand Down
67 changes: 67 additions & 0 deletions MarkdownParseTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import static org.junit.Assert.*;
import org.junit.*;

import java.beans.Transient;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

// javac -cp ".;lib\junit-4.13.2.jar;lib\hamcrest-core-1.3.jar" *.java
// java -cp ".;lib/junit-4.13.2.jar;lib/hamcrest-core-1.3.jar" org.junit.runner.JUnitCore MarkdownParseTest

public class MarkdownParseTest {

@Test
public void addition() {
assertEquals(2, 1 + 1);
}

@Test
public void subtraction() {
assertEquals(0, 1 - 1);
}

@Test
public void getLinksTest1() throws IOException {
Path fileName = Path.of("test-file.md");
String content = Files.readString(fileName);
List<String> expectedLinks = List.of("https://something.com", "some-thing .html");
assertEquals(expectedLinks, MarkdownParse.getLinks(content));
}

@Test
public void getLinksTest2() throws IOException {
Path fileName = Path.of("test-file2.md");
String content = Files.readString(fileName);
List<String> expectedLinks = List.of();
assertEquals(expectedLinks, MarkdownParse.getLinks(content));
}

@Test
public void getLinksTest3() throws IOException {
Path fileName = Path.of("test-file3.md");
String content = Files.readString(fileName);
List<String> expectedLinks = List.of();
assertEquals(expectedLinks, MarkdownParse.getLinks(content));
}

@Test
public void getLinksTest4() throws IOException {
Path fileName = Path.of("test-file4.md");
String content = Files.readString(fileName);
List<String> expectedLinks = List.of();
assertEquals(expectedLinks, MarkdownParse.getLinks(content));
}
}
=======

@Test
public void getLinksMyTest() throws IOException {
Path fileName = Path.of("mytest.md");
String content = Files.readString(fileName);
List<String> expectedLinks = List.of();
assertEquals(expectedLinks, MarkdownParse.getLinks(content));
}
}
>>>>>>> 15651d09b55356d2bba16c937a420101cd9c202e
3 changes: 3 additions & 0 deletions config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Host ieng6
HostName ieng6.ucsd.edu
User cs15lsp22auv
Binary file added lib/hamcrest-core-1.3.jar
Binary file not shown.
Binary file added lib/junit-4.13.2.jar
Binary file not shown.
8 changes: 8 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
MarkdownParse.class: MarkdownParse.java
javac MarkdownParse.java

MarkdownParseTest.class: MarkdownParseTest.java MarkdownParse.class
javac -cp .:lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar MarkdownParseTest.java

test: MarkdownParseTest.class
java -cp .:lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore MarkdownParseTest
1 change: 1 addition & 0 deletions mdparse
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
java -cp lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar:.MarkdownParse $1
7 changes: 7 additions & 0 deletions snippet1
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
`[a link`](url.com)

[another link](`google.com)`

[`cod[e`](google.com)

[`code]`](ucsd.edu)
5 changes: 5 additions & 0 deletions snippet2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[a [nested link](a.com)](b.com)

[a nested parenthesized url](a.com(()))

[some escaped \[ brackets \]](example.com)
24 changes: 24 additions & 0 deletions snippet3
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[this title text is really long and takes up more than
one line

and has some line breaks](
https://www.twitter.com
)

[this title text is really long and takes up more than
one line](
https://sites.google.com/eng.ucsd.edu/cse-15l-spring-2022/schedule
)


[this link doesn't have a closing parenthesis](github.com

And there's still some more text after that.

[this link doesn't have a closing parenthesis for a while](https://cse.ucsd.edu/



)

And then there's more text
2 changes: 1 addition & 1 deletion test-file.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Title

[link1](https://something.com)
[link2](some-thing.html)
[link2](some-thing.html)
3 changes: 3 additions & 0 deletions test-file2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#title

[link](
3 changes: 3 additions & 0 deletions test-file3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# title

[link(
7 changes: 7 additions & 0 deletions test-file4.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# title

[stuff]

paragraph

(page.com)