From 678028678f25f6894afaa2494541117296374d7a Mon Sep 17 00:00:00 2001 From: Xil216 <108439332+Xil216@users.noreply.github.com> Date: Tue, 12 Jul 2022 08:30:51 -0700 Subject: [PATCH 01/11] Create main.yml --- .github/workflows/main.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..18a6a3e --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,36 @@ +# 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: Run a one-line script + run: echo Hello, world! + + # Runs a set of commands using the runners shell + - name: Run a multi-line script + run: | + echo Add other actions to build, + echo test, and deploy your project. From 835cc81ebfa6c165189aa863bfead9a36e91d643 Mon Sep 17 00:00:00 2001 From: Xil216 Date: Tue, 12 Jul 2022 09:13:09 -0700 Subject: [PATCH 02/11] test1 --- MarkdownParse.class | Bin 0 -> 1342 bytes MarkdownParse.java | 12 ++++++++++++ MarkdownParseTest.class | Bin 0 -> 1641 bytes MarkdownParseTest.java | 34 +++++++++++++++++++++++++++++++++- 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 MarkdownParse.class create mode 100644 MarkdownParseTest.class diff --git a/MarkdownParse.class b/MarkdownParse.class new file mode 100644 index 0000000000000000000000000000000000000000..ca7840e05857374a3633bf402641460d246487a1 GIT binary patch literal 1342 zcma)6=~B~R6g^*?HfSK>iU?Y5ff1Kc#~D)^YoMe|nz}rV%OC!# zKakPU2k>cp0JoD;mJT>$W|D6^_ug~vy55^O z)3e1zbHNn|j#;+lW(E9-b1NAj7X90#!zvihXEraW?Nd zmR+W^ifNbKXANh$5IP0KBhRW!#eQf4vSpXdm$Od=Vu}1VmkskwE=ijMw0Rst4~Iku z2RS4?4{;TT&@T|K)r+-ev{)jSOYU~#aUE1Kgu~=vlu82H&R`qDGs%Y$9Klf;$5bSc z6o@wX*j6?D)T)^2Im6T8tCDMGr+Jg>qup_vR9ZY_6pSDx^QPAE~~hLiA}Ms81}%5 zXHl{LQI>lG(qy$n0qtaO&eWHSrgO(AR=CqP?-~nB1!JYT4$oU<+i>d+&&K~(lc{}o+5q%9#)9B}h7 getLinks(String markdown) { int currentIndex = 0; while(currentIndex < markdown.length()) { int openBracket = markdown.indexOf("[", currentIndex); + if(openBracket == -1){ + break; + } int closeBracket = markdown.indexOf("]", openBracket); int openParen = markdown.indexOf("(", closeBracket); + if(openBracket == -1 || closeBracket == -1){ + break; + } int closeParen = markdown.indexOf(")", openParen); + if(openBracket == -1){ + break; + } toReturn.add(markdown.substring(openParen + 1, closeParen)); + currentIndex = closeParen + 1; + } return toReturn; @@ -29,5 +40,6 @@ public static void main(String[] args) throws IOException { String content = Files.readString(fileName); ArrayList links = getLinks(content); System.out.println(links); + } } diff --git a/MarkdownParseTest.class b/MarkdownParseTest.class new file mode 100644 index 0000000000000000000000000000000000000000..3593b87bb27704604a6fd826c5acc1cdf7f9f66a GIT binary patch literal 1641 zcmaJ>X;;%g6uncHln}PED4Q%Iv>-%4K`DZOpkP@9M8!{m4sD=KFqtC!EWc=v=jadc zM|pgchBg&y+tXxb-n;LPxQ69m>-T?`8FK&d9h7HPMZY z*g+W0v?91G#!t))pU5T^M9RwU3CFZj^=L!8f({LLaF-$C(Xvcims$FbA<_&X`-CAL zO_V4Xa^s(FPQ?mSWe9N`!UF}vvfmMgMvqEPm>E4`x+LaI zu+4%q@j#dUj8CMPM;*p6s$fjRLyR*tY#Pp4(*9!Y7>>&s!YM8irgcVb#)1X>CW3HF zj$>R&E`+H~w?LEKrwRk4T{3YIi1V}+rmw2_u=JHri&LAfw8 zIlfIBts{CE^x2OfHCC~v;FX5gSijywo&iP02*q?)v*+T=AeNjiZe8$w($mVcJBfb2n!RGs_Q5*QB*2%d&+bm&n8BMClYtM3P38 zntK*c(qQ%Sn4f#W3ihwb(xF=4F0KSq$g@)ZbZ{_BgFQRv9CLX}NSqtpOh_>?fDO7| zWMT}{X|P1t$B1NB7Kp8JnoO>5zS+wgxE+~pu495?dV1a zc4;K*@BM@S?iT#XApZ3K@Vf}Vo4!32@ehjlb3XsB$de%cY#z@lu Date: Tue, 12 Jul 2022 09:16:31 -0700 Subject: [PATCH 03/11] Update main.yml --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 18a6a3e..8790453 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,5 +32,5 @@ jobs: # Runs a set of commands using the runners shell - name: Run a multi-line script run: | - echo Add other actions to build, - echo test, and deploy your project. + javac -cp .:lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar MarkdownParseTest.java MarkdownParse.java +java -cp .:lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore MarkdownParseTest From a933ec48f38b39509e525e351fae766233b83bd1 Mon Sep 17 00:00:00 2001 From: Xil216 <108439332+Xil216@users.noreply.github.com> Date: Tue, 12 Jul 2022 09:19:26 -0700 Subject: [PATCH 04/11] Update main.yml --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8790453..0ec09dd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,4 +33,4 @@ jobs: - name: Run a multi-line script run: | javac -cp .:lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar MarkdownParseTest.java MarkdownParse.java -java -cp .:lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore MarkdownParseTest + java -cp .:lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore MarkdownParseTest From b4fc7e33eb7089092d504cd74d780ed70f3aa184 Mon Sep 17 00:00:00 2001 From: Xil216 Date: Tue, 12 Jul 2022 09:20:50 -0700 Subject: [PATCH 05/11] test3 --- MarkdownParseTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MarkdownParseTest.java b/MarkdownParseTest.java index 1c16a3a..961da17 100644 --- a/MarkdownParseTest.java +++ b/MarkdownParseTest.java @@ -10,7 +10,7 @@ public class MarkdownParseTest { @Test public void addition(){ - assertEquals(2, 1 + 1); + assertEquals(3, 1 + 1); } From 5f5145da67708da5f5bd8912ed5c5089c4417daa Mon Sep 17 00:00:00 2001 From: Xil216 Date: Tue, 12 Jul 2022 09:22:03 -0700 Subject: [PATCH 06/11] test2 --- MarkdownParseTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MarkdownParseTest.java b/MarkdownParseTest.java index 961da17..1c16a3a 100644 --- a/MarkdownParseTest.java +++ b/MarkdownParseTest.java @@ -10,7 +10,7 @@ public class MarkdownParseTest { @Test public void addition(){ - assertEquals(3, 1 + 1); + assertEquals(2, 1 + 1); } From c7934c8364f8c92c7422ca7c284023e69986608c Mon Sep 17 00:00:00 2001 From: Xil216 Date: Thu, 14 Jul 2022 07:57:58 -0700 Subject: [PATCH 07/11] Create cd --- cd | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 cd diff --git a/cd b/cd new file mode 100644 index 0000000..fde4666 --- /dev/null +++ b/cd @@ -0,0 +1,3 @@ +Host ieng6 + HostName ieng6.ucsd.edu + User cs15ls122au From 4263171e55be493b2934e4609d882f27c9946112 Mon Sep 17 00:00:00 2001 From: Xil216 Date: Thu, 14 Jul 2022 08:34:31 -0700 Subject: [PATCH 08/11] Create Makefile --- lib/Makefile | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 lib/Makefile diff --git a/lib/Makefile b/lib/Makefile new file mode 100644 index 0000000..e69de29 From 258e64b134e6a0974ec87cefd2f54b94f7529697 Mon Sep 17 00:00:00 2001 From: randalateef <108480133+randalateef@users.noreply.github.com> Date: Tue, 19 Jul 2022 09:31:58 -0700 Subject: [PATCH 09/11] lab 7 changes --- MarkdownParseTest.class | Bin 1641 -> 2219 bytes MarkdownParseTest.java | 30 ++++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/MarkdownParseTest.class b/MarkdownParseTest.class index 3593b87bb27704604a6fd826c5acc1cdf7f9f66a..7c66198d11239a3e59e09300827d28ef416880eb 100644 GIT binary patch delta 970 zcma))*-pYx5QhIl3)V(laEaiO>V+H97)66zpvD`6xbM4&1yK|Oy|0On(3ddr$}1Za zeE{FYmoQEX31w+w+MJ#a`^+u7>*+Nk@ zBTADCNBR@@%&v5vUx>G76m>aYC@3j4LG{HjLv3ibJ~US!is(!HxONB^-4qbP;D(3R zV>%7cm+lAm#5>pc6Q=F^;QzcMeaffVNfVe(-`W?CJGWX&R+Bk{0A^0)u z$SGycSx=RVP4pwoaq;Y%2p4;mOVAXf%fn!+U6 zL)4XAZP!T2P?}$+fqvbt-*nbblYWNu;cC6je$&9d&1wJZK0^9=(nlTj*#`Pud-MAZ Wo0qL$Bu4rL(l0vdZ)w;r-2DMo435wM delta 375 zcmZ22_>za~)W2Q(7#JAr7@{_E6*DulGk8z_$K1>qGP#Mxeljnsdc79|6HuOkfsKKY zffY>p0C}=N9wU%u)!NR$xDm);WblP5Vqo9|^8A2GnHWGy)fia7O1VTB*nwyV11CZ~ z7uaxKpbmZpf2jTduxWun{mel9lQ*;K7=w)F19BM{L>PD(L>Z(R#2A8rJdnY`Xc|Ky z8Yc^}=_2Wq0_u|nLK&R;!l3$!*tC)KDFF2;GDtEg;nWun)pvo-fYEm{BfGFXE|*0B JUChJ~2>_4tB!U0{ diff --git a/MarkdownParseTest.java b/MarkdownParseTest.java index 1c16a3a..896bfc9 100644 --- a/MarkdownParseTest.java +++ b/MarkdownParseTest.java @@ -39,4 +39,34 @@ public void testLinks7() throws IOException{ assertEquals(true, MarkdownParse.getLinks(content).isEmpty()); } + //New Test + @Test + public void getCorrectLinks4() throws IOException{ + String content = Files.readString(Path.of("test-file4.md")); + assertEquals(List.of(""),MarkdownParse.getLinks(content)); + } + + //New Test + @Test + public void getCorrectLinks5() throws IOException{ + String content = Files.readString(Path.of("test-file5.md")); + assertEquals(List.of("page.com"),MarkdownParse.getLinks(content)); + } + + //New Test + @Test + public void getCorrectLinks6() throws IOException{ + String content = Files.readString(Path.of("test-file6.md")); + assertEquals(List.of(""),MarkdownParse.getLinks(content)); + } + + //New Test + @Test + public void getCorrectLinks8() throws IOException{ + String content = Files.readString(Path.of("test-file8.md")); + assertEquals(List.of("a link on the first line"),MarkdownParse.getLinks(content)); + } + + + } \ No newline at end of file From 9d4b2b2b80094583c1d0f55a8a08229719cf50f0 Mon Sep 17 00:00:00 2001 From: Xil216 Date: Tue, 19 Jul 2022 09:53:19 -0700 Subject: [PATCH 10/11] Update MarkdownParse.java --- MarkdownParse.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MarkdownParse.java b/MarkdownParse.java index 2c06aca..99b9289 100644 --- a/MarkdownParse.java +++ b/MarkdownParse.java @@ -37,8 +37,8 @@ public static ArrayList getLinks(String markdown) { public static void main(String[] args) throws IOException { Path fileName = Path.of(args[0]); - String content = Files.readString(fileName); - ArrayList links = getLinks(content); + String contentOfFile = Files.readString(fileName); + ArrayList links = getLinks(contentOfFile); System.out.println(links); } From 26f2238fbb3b9eeeb6a471646819bcf4a344046e Mon Sep 17 00:00:00 2001 From: Xil216 Date: Wed, 20 Jul 2022 15:43:32 -0700 Subject: [PATCH 11/11] Update MarkdownParse.java --- MarkdownParse.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/MarkdownParse.java b/MarkdownParse.java index 99b9289..1bf7432 100644 --- a/MarkdownParse.java +++ b/MarkdownParse.java @@ -11,11 +11,8 @@ public static ArrayList getLinks(String markdown) { ArrayList toReturn = new ArrayList<>(); // find the next [, then find the ], then find the (, then read link upto next ) int currentIndex = 0; - while(currentIndex < markdown.length()) { - int openBracket = markdown.indexOf("[", currentIndex); - if(openBracket == -1){ - break; - } + while(currentIndex < markdown.length()||openBracket!=null||closeBracket!=null||openParen!=null||closeParen!=null) { + int openBracket = MarkdownParse.checkOpenBracket(markdown, currentIndex); int closeBracket = markdown.indexOf("]", openBracket); int openParen = markdown.indexOf("(", closeBracket); if(openBracket == -1 || closeBracket == -1){ @@ -34,6 +31,13 @@ public static ArrayList getLinks(String markdown) { return toReturn; } + public static int checkOpenBracket(String markdown, int currentIndex){ + int openBracket = markdown.indexOf("[", currentIndex); + if(openBracket == -1){ + return null; + } + return openBracket; + } public static void main(String[] args) throws IOException { Path fileName = Path.of(args[0]);