Skip to content

Commit

Permalink
feature: add json toggle + copy button to pdf2md
Browse files Browse the repository at this point in the history
  • Loading branch information
skeptrunedev authored and cdxker committed Nov 20, 2024
1 parent eec0b1e commit f898cb5
Show file tree
Hide file tree
Showing 3 changed files with 260 additions and 4 deletions.
64 changes: 60 additions & 4 deletions pdf2md/server/src/templates/demo-ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/notyf@3/notyf.min.css"
/>
<link
rel="stylesheet"
href="https://unpkg.com/@highlightjs/[email protected]/styles/default.min.css"
/>
<script src="https://unpkg.com/@highlightjs/[email protected]/highlight.min.js"></script>
<script src="https://unpkg.com/@highlightjs/[email protected]/languages/json.min.js"></script>
<script>
hljs.highlightAll();
</script>
<style>
.pdfobject-container {
height: 75vh;
Expand All @@ -31,7 +40,8 @@
OCR With Intelligence
</h2>
<p class="mt-2 text-pretty text-lg/8 text-gray-700">
Convert any PDF to LLM-ready Markdown using thrifty vision models like GPT-4o-mini and Gemini-flash-1.5.
Convert any PDF to LLM-ready Markdown using thrifty vision models like
GPT-4o-mini and Gemini-flash-1.5.
</p>
</div>
<button
Expand Down Expand Up @@ -140,17 +150,63 @@
</form>
</div>
<div class="px-4 mt-10 sm:mt-14 md:mt-24 max-w-screen-2xl mx-auto">
<div class="col-span-2 flex justify-between">
<div class="col-span-2 flex justify-between items-center py-1">
<p id="document-price" class="text-gray-600 text-sm/6"></p>
<div class="flex items-center gap-2">
<button
type="button"
class="inline-flex items-center gap-x-1.5 rounded-md bg-magenta-600 px-2.5 py-1.5 text-sm font-semibold text-white shadow-sm hover:bg-magenta-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-magenta-600"
id="copy-button"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
fill="currentColor"
class="bi bi-copy"
viewBox="0 0 16 16"
>
<path
fill-rule="evenodd"
d="M4 2a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2zm2-1a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1zM2 5a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-1h1v1a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h1v1z"
/>
</svg>
Copy
</button>
<div class="flex items-center">
<button
type="button"
class="relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent bg-gray-200 transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-magenta-600 focus:ring-offset-2"
role="switch"
aria-checked="false"
aria-labelledby="json"
id="json-switch"
>
<span
aria-hidden="true"
class="pointer-events-none inline-block size-5 translate-x-0 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"
></span>
</button>
<span class="ml-3 text-sm" id="json">
<span class="font-medium text-gray-900">Json</span>
</span>
</div>
</div>
</div>
<div id="result-container" class="grid grid-cols-2 gap-4">
<div id="my-pdf"></div>
<div id="markdown-container" class="max-h-[75vh] overflow-y-auto"></div>
<pre id="json-pre" class="hidden max-h-[75vh] overflow-y-auto">
<code class="language-json" id="json-container"></code>
</pre>
</div>
</div>
<div class="flow-root">
<div class="mt-10 sm:mt-14 md:mt-24 pt-4 border border-gray-900 hidden"></div>
<div class="my-4 animate-pulse hidden h-1 bg-gray-700"></div>
<div
class="mt-10 sm:mt-14 md:mt-24 pt-4 border border-gray-900 bg-magenta-600 translate-x-5 hidden"
></div>
<div class="my-4 animate-pulse hidden h-1 bg-gray-700 translate-x-0"></div>
<div class="hidden bg-gray-200"></div>
</div>
<div
id="task-status-table-container"
Expand Down
153 changes: 153 additions & 0 deletions pdf2md/server/static/output.css
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,10 @@ video {
border-width: 0;
}

.pointer-events-none {
pointer-events: none;
}

.relative {
position: relative;
}
Expand Down Expand Up @@ -604,6 +608,10 @@ video {
margin-bottom: 1rem;
}

.ml-3 {
margin-left: 0.75rem;
}

.mt-10 {
margin-top: 2.5rem;
}
Expand Down Expand Up @@ -636,6 +644,10 @@ video {
display: flex;
}

.inline-flex {
display: inline-flex;
}

.table {
display: table;
}
Expand All @@ -657,6 +669,11 @@ video {
height: 3rem;
}

.size-5 {
width: 1.25rem;
height: 1.25rem;
}

.h-1 {
height: 0.25rem;
}
Expand All @@ -665,10 +682,18 @@ video {
height: 3rem;
}

.h-6 {
height: 1.5rem;
}

.max-h-\[75vh\] {
max-height: 75vh;
}

.w-11 {
width: 2.75rem;
}

.w-12 {
width: 3rem;
}
Expand All @@ -689,6 +714,24 @@ video {
max-width: 1536px;
}

.shrink-0 {
flex-shrink: 0;
}

.translate-x-0 {
--tw-translate-x: 0px;
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

.translate-x-5 {
--tw-translate-x: 1.25rem;
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

.transform {
transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));
}

@keyframes pulse {
50% {
opacity: .5;
Expand Down Expand Up @@ -723,10 +766,19 @@ video {
justify-content: space-between;
}

.gap-2 {
gap: 0.5rem;
}

.gap-4 {
gap: 1rem;
}

.gap-x-1\.5 {
-moz-column-gap: 0.375rem;
column-gap: 0.375rem;
}

.gap-x-2 {
-moz-column-gap: 0.5rem;
column-gap: 0.5rem;
Expand Down Expand Up @@ -781,6 +833,10 @@ video {
text-wrap: pretty;
}

.rounded-full {
border-radius: 9999px;
}

.rounded-lg {
border-radius: 0.5rem;
}
Expand All @@ -797,6 +853,10 @@ video {
border-width: 0px;
}

.border-2 {
border-width: 2px;
}

.border-dashed {
border-style: dashed;
}
Expand All @@ -810,11 +870,25 @@ video {
border-color: rgb(17 24 39 / 0.25);
}

.border-transparent {
border-color: transparent;
}

.bg-gray-200 {
--tw-bg-opacity: 1;
background-color: rgb(229 231 235 / var(--tw-bg-opacity));
}

.bg-gray-700 {
--tw-bg-opacity: 1;
background-color: rgb(55 65 81 / var(--tw-bg-opacity));
}

.bg-magenta-600 {
--tw-bg-opacity: 1;
background-color: rgb(125 48 139 / var(--tw-bg-opacity));
}

.bg-white {
--tw-bg-opacity: 1;
background-color: rgb(255 255 255 / var(--tw-bg-opacity));
Expand All @@ -832,6 +906,11 @@ video {
padding: 2rem;
}

.px-2\.5 {
padding-left: 0.625rem;
padding-right: 0.625rem;
}

.px-3 {
padding-left: 0.75rem;
padding-right: 0.75rem;
Expand All @@ -852,6 +931,11 @@ video {
padding-right: 2rem;
}

.py-1 {
padding-top: 0.25rem;
padding-bottom: 0.25rem;
}

.py-1\.5 {
padding-top: 0.375rem;
padding-bottom: 0.375rem;
Expand Down Expand Up @@ -998,12 +1082,29 @@ video {
color: rgb(125 48 139 / var(--tw-text-opacity));
}

.text-white {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity));
}

.shadow {
--tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
--tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}

.shadow-sm {
--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
}

.ring-0 {
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color);
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
}

.ring-1 {
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);
Expand All @@ -1019,6 +1120,28 @@ video {
--tw-ring-color: rgb(209 213 219 / var(--tw-ring-opacity));
}

.transition {
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter, -webkit-backdrop-filter;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms;
}

.transition-colors {
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 150ms;
}

.duration-200 {
transition-duration: 200ms;
}

.ease-in-out {
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.placeholder\:text-gray-400::-moz-placeholder {
--tw-text-opacity: 1;
color: rgb(156 163 175 / var(--tw-text-opacity));
Expand Down Expand Up @@ -1049,6 +1172,11 @@ video {
--tw-ring-offset-width: 2px;
}

.hover\:bg-magenta-500:hover {
--tw-bg-opacity: 1;
background-color: rgb(163 62 181 / var(--tw-bg-opacity));
}

.hover\:text-magenta-500:hover {
--tw-text-opacity: 1;
color: rgb(163 62 181 / var(--tw-text-opacity));
Expand All @@ -1059,6 +1187,11 @@ video {
color: rgb(12 5 14 / var(--tw-text-opacity));
}

.focus\:outline-none:focus {
outline: 2px solid transparent;
outline-offset: 2px;
}

.focus\:ring-2:focus {
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
Expand All @@ -1074,6 +1207,26 @@ video {
--tw-ring-color: rgb(125 48 139 / var(--tw-ring-opacity));
}

.focus\:ring-offset-2:focus {
--tw-ring-offset-width: 2px;
}

.focus-visible\:outline:focus-visible {
outline-style: solid;
}

.focus-visible\:outline-2:focus-visible {
outline-width: 2px;
}

.focus-visible\:outline-offset-2:focus-visible {
outline-offset: 2px;
}

.focus-visible\:outline-magenta-600:focus-visible {
outline-color: #7D308B;
}

@media (min-width: 640px) {
.sm\:-mx-6 {
margin-left: -1.5rem;
Expand Down
Loading

0 comments on commit f898cb5

Please sign in to comment.